Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Add currentDate as an extra property in the opsgenie_configs

soundarya sivagurunathan December 9, 2024

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?

3 answers

0 votes
Shashwat Khare
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 11, 2024

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

0 votes
soundarya sivagurunathan December 10, 2024

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:

Screenshot 2024-12-10 at 3.39.55 PM.png

 

Close Alert:Screenshot 2024-12-10 at 3.37.20 PM.png

0 votes
soundarya sivagurunathan December 10, 2024
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

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
ENTERPRISE
TAGS
AUG Leaders

Atlassian Community Events