Get key value from a go template in Prometheus/Alertmanager/Jiralert attempt to map severity to Jira task

I am using Prometheus Alertmanager integration with Jiralert go tool to create tasks out of alerts in Jira.
Everything works as expected aside from the fact that I don’t know how to inherit severity from the current alert. I am hard-coding a value at this point. I have tried to get the value from .Labels (which is get successfully during template, but not if I call it from config yaml.

# Content of jiralert.yaml
# Global defaults, applied to all receivers where not explicitly overridden. Optional.
  # API access fields.
  user: ''
  password: 'randompassword'

  # The type of JIRA issue to create. Required.
  issue_type: Alert
  # Issue priority. Optional.
  #priority: Low
  # Go template invocation for generating the summary. Required.
  summary: '{{ template "jira.summary" . }}'
  # Go template invocation for generating the description. Optional.
  description: '{{ template "jira.description" . }}'
  # State to transition into when reopening a closed issue. Required.
  reopen_state: "To Do"
  # Do not reopen issues with this resolution. Optional.
  wont_fix_resolution: "Won't Fix"
  # Amount of time after being closed that an issue should be reopened, after which, a new issue is created.
  # Optional (default: always reopen)
  reopen_duration: 0h

# Receiver definitions. At least one must be defined.
# Non-prod cluster for testing
  - name: 'prometheus-test-non-production'
    # JIRA project to create the issue in. Required.
    summary: '{{ template "jira.testenv.summary" . }}'
    description: '{{ template "jira.testenv.description" . }}'
    project: AS
    # Copy all Prometheus labels into separate JIRA labels. Optional (default: false).
    add_group_labels: false
      customfield_10600: { "value": '{{ template ".Alerts.Front().Labels.severity.Value" }}' }
template: jiralert_v2.tmpl
# jiralert_v2.tmpl
{{ define "jira.summary" }}{{end}}
{{ define "jira.description" }}{{end}}

{{ define "jira.testenv.summary" }}[Prometheus][K8s/testenv-ops][{{ .Status | toUpper }}{{- if eq .Status "firing" -}}:{{- .Alerts.Firing | len -}}{{- end -}}]{{ .CommonLabels.alertname }} for {{ .CommonLabels.job }}{{- end }}{{- if gt (len .CommonLabels) (len .GroupLabels) -}}{{" "}}({{- with .CommonLabels.Remove .GroupLabels.Names }}{{- range $index, $label := .SortedPairs -}}{{ if $index }}, {{ end }}{{- $label.Name }}="{{ $label.Value -}}"{{- end }}{{- end -}}){{- end }}
{{ define "jira.testenv.description" }}
    {{ with index .Alerts 0 -}}
    *URL: <{{ .GeneratorURL }}>*
    {{- if .Annotations.runbook }} :notebook: *<{{ .Annotations.runbook }}|Runbook>*{{ end }}
    {{ end }}
    Kubernetes Cluster: testenv-ops
    Prometheus Alert Details:
    {{ range .Alerts}}
      * Alert Labels:
    {{ range .Labels.SortedPairs }}    ** {{ .Name }}: {{ .Value }}
    {{ end }}
      * Alert Description: {{ .Annotations.message }}
    {{ end }}
{{- end }}

Go to Source
Author: anVzdGFub3RoZXJodW1hbg

Is there a way to make Prometheus to scrape only the metrics which are present in Grafana?

As a customer of Grafna Cloud, I need to minimize the number of DataSeries that are being sent (remote_write) to Grafana Cloud, to avoid being overcharged for metrics that I don’t really use.

This can be done by filtering out the metrics that I don’t use in my Grafana dashboards, is there a way to do that automatically? Without having to write down all the metric_relabel_configs rules manually?

Go to Source
Author: Meir Gabay