Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
Level
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

Insight + Groovy Script => Found and assign automatically the Servers? Almost the solution :-) Edited

Hello,

i already contacted Insight support about my demand, they said i need to do it by Groovy Script : 

I have an object type called "Servers". All server are automatically added using the discovery. An specific Attribute for each object called FQDN, it's simply the full name of the servers. Exemple : AFDAOS.fr***.int. 

To monitore our server, we using Centreon (based on nagios), when we have a critical alert, an email is sent to mailbox Jira who create the issue. The subject of the mail is our summary. Exemple : ** PROBLEM alert - AFDAOS.f***.int/AX TEST Service is CRITICAL **.

The result expected : Assign automatically the good server depending of the summary. In this case, the system need to found the part "AFDAOS.fr***.int" inside the summary and automatically assign it to this object inside a specific custom field insight. We already try (we Mindville support ) to do it using IQL but it's not working with the LIKE command.

I never use Groovy script and i don"t have any idea how to start to do it. It doesn't seem too complicated but i need help to start.
2020-06-24 12_40_37-Insight - AF Jira.png2020-06-24 12_41_34-[IT-6741] __ PROBLEM alert - AFDAOS.francois.int_AX TEST Service is CRITICAL __ .png
Thank you !

1 answer

Hello... I'm learned Groovy (as much as i can) and i'm almost the result i want ! 

Here my code :

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CustomField
import com.riadalabs.jira.plugins.insight.services.model.CommentBean;
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.event.type.EventDispatchOption
import com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade
import com.riadalabs.jira.plugins.insight.services.model.ObjectAttributeBean
import com.riadalabs.jira.plugins.insight.services.model.ObjectBean

 

Class objectFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade");
def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectFacadeClass);

Class iqlFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.IQLFacade");
def iqlFacade = ComponentAccessor.getOSGiComponentInstanceOfType(iqlFacadeClass);

def objects = iqlFacade.findObjectsByIQLAndSchema(10,"objectTypeId = 2443");
//def test = "AF-172738"
//def ObjectInsightBean = objectFacade.loadObjectBean(test)
//log.warn("ObjectInsightBean " + ObjectInsightBean)
def n = 0
(objects).each {
CurrentObject = objects[n]
def FQDNValue = objectFacade.loadObjectAttributeBean(CurrentObject.getId(),47464).getObjectAttributeValueBeans()[0]; //Load Attribute Value
log.warn("Server " + objects[n])
//log.warn("FQDNValue " + FQDNValue)
//FQDNValueSTR = FQDNValue.ToString()
log.warn("FQDNValue " + FQDNValue)
result = (issue.getSummary().contains(FQDNValue))

log.warn("result " + result)
n ++

The output is : 

2020-06-29 16:45:28,650 [http-nio-8080-exec-17] | Server AFAW16-FS01 (AF-173140)
2020-06-29 16:45:28,650 [http-nio-8080-exec-17] | FQDNValue [2629351(AFAW16-FS01.francois.int)]

I have the following error :

GroovyInsightException: No signature of method: java.lang.String.contains() is applicable for argument types: (com.riadalabs.jira.plugins.insight.services.model.ObjectAttributeValueBean) values: [[2629351(AFAW16-FS01.francois.int)]] Possible solutions: contains(java.lang.CharSequence), contains(java.lang.CharSequence), toString(), toString(), toString(), notify()'

 

The problem is i want use the contain in (issue.getSummary().contains(FQDNValue)), FQDNValue have the good value but seems not be string value. It's [2629351(AFAW16-FS01.xxxx.int) (what's the 2629351 value?? I just want compare the AFAW16-FS01.xxxx.int . 

Have i to import a specific plugin, use another syntax? I tried FQDNValueSTR = FQDNValue.ToString() but it's not working....

Thank you !!

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

New Cloud Apps Roundup - Spring 2021

Atlassian's marketplace partners have had a very productive start to 2021! Since our last roundup, our developer community has added over 160 new cloud apps to the Atlassian Marketplace to help you...

214 views 3 20
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