VictoriaMetrics/app
Aliaksandr Valialkin 7ae038766c
app/vmalert/templates: properly escape all the special chars in quotesEscape function
Previously the `quotesEscape` function was escaping only double quotes.
This wasn't enough, since the input string could contain other special chars,
which must be escaped when put inside JSON string. For example, carriage return and line feed chars (\n\r),
backslash char, etc. This led to the following issues, which were improperly fixed:

- https://github.com/VictoriaMetrics/VictoriaMetrics/issues/890 - this issue
  was "fixed" by introducing the `crlfEscape` function, which led to unnecessary
  complications in user templates, while not fixing various corner cases
  such as backslash chars in the input string.
  See 1de15ad490

- https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3139 - this issue
  was "fixed" by urlencoding the whole string passed to -external.alert.source
  command-line flag. This led to invalid urls, which couldn't be parsed by Grafana.
  See 00c838353d
  and 4bd0244599

This commit properly encodes the input string passed to `quotesEscape`, so it can be safely embedded inside JSON strings.

This commit deprecates crlfEscape template function and adds the following new template functions:

- strvalue and stripDomain - these functions are supported by Prometheus, so they were added
  for compatibility purposes.
- jsonEscape and htmlEscape for converting the input string to valid quoted JSON string
  and for html-escaping the input string, so it could be safely embedded as a plaintext
  into html.

This commit also documents all supported template functions at https://docs.victoriametrics.com/vmalert.html#template-functions
The deprecated crlfEscape function isn't documented on purpose, since its usefulness is negative in general case.
2022-10-28 00:08:50 +03:00
..
vmagent docs/enterprise.md: describe all the enteprise features in a short doc at https://docs.victoriametrics.com/enterprise.html 2022-10-24 18:03:22 +03:00
vmalert app/vmalert/templates: properly escape all the special chars in quotesEscape function 2022-10-28 00:08:50 +03:00
vmauth lib/envtemplate: allow referring env vars from other env vars via %{ENV_VAR} syntax 2022-10-26 14:51:02 +03:00
vmbackup doc: describe usage of env variables for obtaining credentials (#3219) 2022-10-12 09:33:16 +03:00
vmbackupmanager docs/enterprise.md: describe all the enteprise features in a short doc at https://docs.victoriametrics.com/enterprise.html 2022-10-24 18:03:22 +03:00
vmctl all: update the minimum required Go verson from 1.19.1 to 1.19.2 2022-10-07 22:46:44 +03:00
vmgateway docs/enterprise.md: describe all the enteprise features in a short doc at https://docs.victoriametrics.com/enterprise.html 2022-10-24 18:03:22 +03:00
vminsert app/{vminsert,vmselect}/netstorage: allow calling Init()+MustStop() in a loop 2022-10-25 14:43:05 +03:00
vmrestore docs/vmbackupmanager.md: update docs after adding the support to make backups to Azure blob storage 2022-10-08 10:30:58 +03:00
vmselect app/vmselect/vmui: make vmui-update after eae6063450 2022-10-26 02:51:09 +03:00
vmstorage lib/storage: add support for retention filters (aka multiple retentions for distinct sets of time series) 2022-10-24 16:41:59 +03:00
vmui fix: change step setting field (#3270) 2022-10-26 02:47:41 +03:00