Ad Widget

Collapse

JSONPath evaluation problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AJW
    Junior Member
    • Jul 2022
    • 5

    #1

    JSONPath evaluation problem

    I've created a new item for MSSQL monitoring to get the alerts (different severities and the occurrence value
    Being done as a discovery as need an item created per alert severity and their occurrence

    Item - Database monitor
    Select name as AlertName , occurrence_count as Occurrence from msdb.dbo.sysalerts where severity > 0

    This produces currently the output (only one entry in the database at the moment)
    [{"AlertName":"Error 17 Alert","Occurrence":"0"}]

    Discovery created
    select name as AlertName from msdb.dbo.sysalerts where severity > 0

    Dependent item created using the discovery (Numeric(Unsigned)

    Preprocessing created
    $[?(@.AlertName == '{#ALERTNAME}')].Occurrance.first()

    Produces the error;
    Preprocessing failed for: 0
    1. Failed: cannot extract value from json by path "$[?(@.AlertName=='Error 17 Alert')].Occurrence.first()": cannot parse as a valid JSON object: invalid object format, expected opening character '{' or '[' at: '0'​

    Now at a loss as to where the problem lies

    Used the Job Discovery \ Get Job Status item as a template. The output from which looks in the same format as the one above (albeit with more entries returned)

    Any one with any ideas where I'm going wrong ?
    Any help greatly appreciated


  • AJW
    Junior Member
    • Jul 2022
    • 5

    #2
    Update: Just realised when typing here I put in a typo;
    Preprocessing created
    $[?(@.AlertName == '{#ALERTNAME}')].Occurrance.first()
    should read
    Preprocessing created
    $[?(@.AlertName == '{#ALERTNAME}')].Occurrence.first()​​

    Comment

    Working...