Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: The recommended external.alert.source for Grafana does not work #1994

Open
tropnikovvl opened this issue Feb 12, 2025 · 7 comments
Open

Comments

@tropnikovvl
Copy link

Chart name and version
chart: victoria-metrics-k8s-stack
version: latest

Describe the bug
The documentation recommends adding these flags

./bin/vmalert \
    -external.url=http://<grafana-addr> \  # the hostname and port for Grafana 
    -external.alert.source='explore?left={"datasource":"VictoriaMetrics","queries":[{"expr":{{ .Expr|jsonEscape|queryEscape }},"refId":"A"}],"range":{"from":"{{ .ActiveAt.UnixMilli }}","to":"now"}}'

When I try to add them to the chart I get an error

Error: template: victoria-metrics-k8s-stack/templates/victoria-metrics-operator/vmalert/vmalert.yaml:17:9: executing "victoria-metrics-k8s-stack/templates/victoria-metrics-operator/vmalert/vmalert.yaml" at <include "vm.alert.spec" $ctx>: error calling include: template: victoria-metrics-k8s-stack/templates/_helpers.tpl:131:6: executing "vm.alert.spec" at <tpl (deepCopy (omit $Values.vmalert.spec "notifiers") | mergeOverwrite $vmAlertRemotes | mergeOverwrite $vmAlertTemplates | mergeOverwrite $spec | toYaml) .>: error calling tpl: cannot parse template "configMaps: []\ndatasource:\n url: http://vmsingle-release-name-victoria-metrics-k8s-stack.default.svc.cluster.local.:8429\nevaluationInterval: 20s\nexternalLabels: {}\nextraArgs:\n external.alert.source: explore?left={"datasource":"VictoriaMetrics","queries":[{"expr":"{{.Expr|jsonEscape|queryEscape}}","refId":"A"}],"range":{"from":"{{.ActiveAt.UnixMilli}}","to":"now"}}\n external.url: https://grafana.fofo.ro\n http.pathPrefix: /\n remoteWrite.disablePathAppend: "true"\nimage:\n tag: v1.111.0\nlicense: {}\nnotifiers:\n- url: http://vmalertmanager-release-name-victoria-metrics-k8s-stack-0.vmalertmanager-release-name-victoria-metrics-k8s-stack.default.svc.cluster.local.:9093\nport: "8080"\nremoteRead:\n url: http://vmsingle-release-name-victoria-metrics-k8s-stack.default.svc.cluster.local.:8429\nremoteWrite:\n url: http://vmsingle-release-name-victoria-metrics-k8s-stack.default.svc.cluster.local.:8429/api/v1/write\nselectAllByDefault: true": template: gotpl:7: function "jsonEscape" not defined

Custom values

external:
  grafana:
    host: grafana.fofo.ro

vmalert:
  enabled: true
  spec:
    extraArgs:
      external.url: https://grafana.fofo.ro
      external.alert.source: 'explore?left={"datasource":"VictoriaMetrics","queries":[{"expr":"{{.Expr|jsonEscape|queryEscape}}","refId":"A"}],"range":{"from":"{{.ActiveAt.UnixMilli}}","to":"now"}}'
@tiny-pangolin
Copy link

I ran into something similar recently with docker compose, does removing the ' at the beginning and end of the external.alert.source value work for you?

@tropnikovvl
Copy link
Author

@tiny-pangolin unfortunately no

@AndrewChubatiuk
Copy link
Collaborator

looks like you need to escape template as first helm renders it and then it's rendered by vmalert

@tropnikovvl
Copy link
Author

How can I do it?

@AndrewChubatiuk
Copy link
Collaborator

suppose it should be something like this

vmalert:
  spec:
    extraArgs:
      external.alert.source: 'explore?left={"datasource":"VictoriaMetrics","queries":[{"expr":"{{"{{"}}.Expr|jsonEscape|queryEscape{{"}}"}}","refId":"A"}],"range":{"from":"{{"{{"}}.ActiveAt.UnixMilli{{"}}"}}","to":"now"}}'

@tropnikovvl
Copy link
Author

@AndrewChubatiuk thank you,
Maybe it makes sense to add this parameter by default in the chart, provided that an external Grafana is specified?
With the ability to override the datasource name

@tropnikovvl
Copy link
Author

tropnikovvl commented Feb 18, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants