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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,559,427
Community Members
 
Community Events
184
Community Groups

Website Check Script - if down, create task

Has anyone ever written a script that touches an external (to Jira) webpage every hour or so, and performs some action in Jira based on the response code?

I manage a bunch of web apps, and would love to get Jira issues sent to me when a site responds with something other than a 200?  Create a new issue in a project with details on the site that failed the status check.

Ideally, I would have a bunch of parent issues for the sites, and if there is a problem with a site, a subtask is created under the site’s parent issue. That way, I could add more sites to the checker over time, and let the script loop through all of the main issues. 

We are running Jira Server v9.7, and the latest Scriptrunner & Automation plugins. 

Anyone have experience touching external sites with scriptrunner? Even though I’m not fluent with groovy, I could probably piece together the rest of the script myself using previous community posts and the Adaptivist Library (and ChatGPT…LOL). 

Thanks all!

2 answers

1 vote
Graham Twine
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 19, 2023 • edited

Hello @Timothy Ryner

 

Is Jira the right place to be monitoring health of another system though?

If you have scriptrunner then you  can create a Job that is scheduled.

 

There are a number of ways to do this but I guess as this is in groovy lets use this.

Have a look at groovyx.net.http.HttpResponseDecorator

 

import groovyx.net.http.ContentType
import groovyx.net.http.HTTPBuilder
import groovyx.net.http.Method
import groovyx.net.http.HttpResponseDecorator


log.info(
"Checking if the system is running.")

def host = 'https://host.domain.com'
def http = new HTTPBuilder(host)

http.request(Method.GET) { req ->

uri.path = '/rest/api/latest/myself'
headers.'APIKEY' = 'i-need-a-key'
response.success = { HttpResponseDecorator resp, data ->
log.info "System running: ${resp.statusLine}"
}
response.failure = { HttpResponseDecorator resp ->
// create an issue in Jira
createIssue(
}

}


def createIssue(String code, String system...) {

}

 

Radek Dostál
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 22, 2023

HTTP utilities aside, I would focus on the point Graham mentioned - you don't want to turn Jira into a monitoring tool, because it isn't suited for it and it's just a "tool" between monitoring and the target site. Whatever it is you're about to do, there are better apps to do it, rather than creating some inline scripts you have virtually zero control of. What if the jobs stop working? How will you solve logging? What if Jira isn't working, is the monitoring in turn also not working? What if the automation user gets inactivated / loses permissions? This is prone to a lot of chained issues that you would be trying to solve over a long period of time and it still will have a room for error. Jira is not the right tool to do monitoring from, and by using it so you will eventually, most likely, hit some of the guardrails and degrade performance of the instance.

I had my experience with people trying to make their projects work as databases, monitorings, log collectors, and it was always ugly and resulted in them going away using proper tools for the job, rather than pulling the entire instance down because of their rather dull automation (which they found to be failing on several occasions). Guardrails are real, and they do bite if you use Jira for something it wasn't meant to do.

Thanks Graham for the start!  I'll fiddle with this over the coming weeks!  

Hi @Timothy Ryner 

I’m Madeleine, the Product Manager of a new ScriptRunner for integrations app by Adaptavist called Stitch It.

As the others have said, Jira may not be an optimal monitoring tool. If you do however decide to proceed with your implementation Stitch It could facilitate this for you (and any other integrations you might need between your bespoke tools and your Jira On-Premise).

We don’t have a bespoke template (Stitch It equivalent to a ScriptRunner Library script) that does exactly what you need, but we have a template that demonstrated how to hit a URL and inspect the status code and a template to create an issue in Jira on-prem, if you look at these templates hopefully you can stitch together a script and hook them up with our scheduled trigger to run your integration periodically. In case you need to connect to Jira on-prem instance behind the firewall, here are instructions on how to achieve it.

If you want to learn more about Stitch It you can also head over to our website here.

This is a neat tool!  I work in an interesting environment with many of the exact issues outlined in the marketing slick.  Now knowing this exists, I'll look at our processes through a different lens, and I might see about getting funding.  Thanks!

Great, I'm very glad to hear it! You can test the app for free for a few more months until we come out of Beta, otherwise feel free to contact us via the website or via email directly (mvironda@adaptavist.com) and we'd be happy to arrange a demo!

Like Timothy Ryner likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
9.7.1
TAGS
AUG Leaders

Atlassian Community Events