I'm looking to create custom query on SolarWinds to show the status of a SQL job, but I want to be able to view the last 5 times (if that makes sense)
I have found this prebuilt query on THWACK (SQL Agent Job Status - Forum - Server & Application Monitor (SAM) - THWACK (solarwinds.com)) already but I'm struggling to get it to bring more than one day's worth of data.
SELECT DISTINCT n.Caption AS [Node]
, app.Name AS [Name]
, app.LastRunDate AS [Last Run Date]
, app.JobStatus AS [Job Status]
, CASE
WHEN app.JobStatus = 'Up'
THEN '/Orion/APM/SqlBlackBox/Images/StatusIcons/job_succeeded.png'
ELSE '/Orion/APM/SqlBlackBox/Images/StatusIcons/job_failed.png'
END AS [_Iconfor_Job Status]
, n.DetailsUrl AS [_LinkFor_Node]
, sql.DetailsUrl AS [_linkfor_Name]
FROM Orion.APM.SqlJobInfoAlert app
JOIN Orion.Nodes n
ON n.nodeid = app.nodeid
JOIN Orion.apm.SqlJobInfo sql
ON app.ApplicationID = sql.ApplicationID
WHERE app.name = 'XXX'
AND app.name = 'XXX'
AND n.caption = 'XXX'
ORDER BY app.Jobstatus
We regularly have jobs fail due to memory and we monitor this over a 4-day period and if on the 3rd day its failed again we would investigate. We want a simple way to check if the job has been failing more than 3 days.