Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to use projectKey as variable in OEC

Dear all,

i am using opsgenie ,OEC and Python Script for creating some jira issues with some custom jira fields which are not filled by default,the synchronization opsgenie-jira works fine and the jira tickets are created.In order to use the py script i have to define the projectKey within config.json like below:

{
"apiKey": "",
"baseUrl": "",
"logLevel": "DEBUG",
"globalArgs": [],
"globalFlags": {
"url": "https://jira....",
"username": "tec-opsgenie",
"password": "
"issueTypeName": "Incident",
"projectKey": "CFORQ"
},

 

Now every alert will create a ticket under Q-Queue but since i have different alerts for different projects i want tickets to be created for project specific queue.Let say i have project which is called BMW and another project wich is called Audi.

How to create BMWA-123 tickets for all BMW alerts and AUDIA-123 for all Audi alerts?Why the projectKey is hardcoded?Hardcoding the projecKey means that i must have different OEC instances for different projects,but what if i have more than 100 projects.

1 answer

1 accepted

2 votes
Answer accepted
Samir Atlassian Team Jan 14, 2022

Hi @Oalimerko ,

 

Does the alert in Opsgenie contains some field which indicates which project it should get created in? i.e. does the alert contain "BMW" or "Audi" in one of the fields?

 

If so - you could step conditional logic using if-then statements in your script to set the projectKey based on the value of the field in the alert.

e.g. if-then statements checking if BMW or Audi is in the message field of the alert, and setting the projectKey field accordingly

if BMW in queue_message.get("message"):

  projectKey = "BMW"

elif Audi in queue_message.get("message"):

  projectKey = "AUDI"

 

Thanks,

Samir

Hi @Samir ,

yes the description of alerts contains a field which specifies the name of the project.With regex i can pick out the project ,i.e

projectKey = re.search(r"project:\s\'(.*)[']",queue_message.get("description"))

because using if-then for 100 projects it's not realistic.But what will happen with projectKey defined in config.json?

Samir Atlassian Team Jan 14, 2022

@Oalimerko If there are that many projects, then yeah using regex would probably be better than if-then statements. 

 

The projectKey from the config.json should be overridden by whatever the projectKey is set in the script.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS
Community showcase
Published in Opsgenie

Leveraging Atlassian’s Opsgenie and AWS Cloudformation Registry to stay ahead of incidents

In the past, managing IT infrastructure was a hard job. It required a lot of manual effort and it was hard to keep track of all the necessary information (monitoring, scalability etc). Thankfully, as...

2,368 views 0 13
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you