Is there a way to get the currentDate as an extra property or as a label so that it can be used as part of my alias in the opsgenie integration?
I tried to add it as an extra property to the opsgenie_configs in our alertmanager configuration like below:
receivers:
- name: opsgenie
opsgenie_configs:
- api_key: MY_API_KEY
extra_properties:
- key: currentDate
value: '{{`{{ now.Format "YYYY-MM-DD" }}`}}"
message: >
{{ "{{" }}`{{`{{ .GroupLabels.alertName }}: ({{ .GroupLabels.cluster }} {{ .CommonAnnotations.description }}`}}`{{ "}}" }}
and then tried to use this currentDate as part of the alias in the opsgenie prometheus integration.
{{extraProperties.cluster}}/{{extraProperties.currentDate}}
The output of alias is just test-cluster/
I don't see the currentDate available in the extraProperties. What is the correct way to do this?
Hi @soundarya sivagurunathan ,
This is Shashwat from Opsgenie and here to help! :)
I'm glad that you were able to add the currentDate as an extra property for the Opsgenie alert.
Here's a great blog post that explains in detail how to extract custom fields and data into an Alert:
https://community.atlassian.com/t5/Opsgenie-articles/How-to-Extract-Custom-Fields-and-Data-into-an-Alert/ba-p/2133902
For the close alert automation to work, please note that the alias mapping should be the same for Opsgenie to identify the resolved/recovered event belongs to the same alert in Opsgenie that's currently open/acknowledged.
Next, the action filters should be uniquely configured for filter values like status=open in the create alert action filter and status=resolved/closed in the close alert action filter for the automation to auto-close such alerts at the integration level itself.
Here's a great blog post on how to configure the alias field on the integration level:
https://community.atlassian.com/t5/Opsgenie-articles/Configuring-the-Opsgenie-Alias-Field/ba-p/2520231
Best,
Shashwat
receivers:
- name: opsgenie
opsgenie_configs:
- api_key: MY_API_KEY
details:
currentDate: {{ now | date "2006-01-02 }}
message: >
{{ "{{" }}`{{`{{ .GroupLabels.alertName }}: ({{ .GroupLabels.cluster }} {{ .CommonAnnotations.description }}`}}`{{ "}}" }}
Able to add currentDate as an extra property with the right opsgenie_config. It is fixed it now.
https://prometheus.io/docs/alerting/latest/configuration/#opsgenie_config
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have a follow up question. The create alert and close alert have the same alias and once the alert recovers/resolved, it doesn't close the alert automatically. How to handle this when using custom alias?
Create Alert:
Close Alert:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.