Ad Widget

Collapse

Monitorando Json

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Bruno Mazzo Feitosa
    Junior Member
    • Feb 2020
    • 4

    #1

    Monitorando Json

    Prezados, boa tarde,

    Estou com uma dificuldade de configurar um monitoramento em Json no zabbix.

    Quando vou criar o pre-processamento do jsonpath sem apresenta o erro "no data matches the specified path"

    Ja olhei o https://www.zabbix.com/documentation/current/manual/appendix/preprocessing/jsonpath_functionality e utilizei diversas sintaxes para criar esse jsonpath e não funciona

    Segue abaixo o resultado que o json retorna:
    {"body":[{"Name":"CARRINHO","CurrentCount":0,"LastCount":22 ,"Children":[],"Performance":4.0},{"Name":"EFETIVA","CurrentCoun t":0,"LastCount":8,"Children":[],"Performance":12.0},{"Name":"CONFIRMA","CurrentCo unt":0,"LastCount":1,"Children":[],"Performance":100.0},{"Name":"ANULA","CurrentCoun t":0,"LastCount":0,"Children":[],"Performance":100.0}]}
    Click image for larger version

Name:	json resultado mozilla.PNG
Views:	356
Size:	12.8 KB
ID:	396436
    Click image for larger version

Name:	caminhojson.PNG
Views:	343
Size:	15.3 KB
ID:	396437
  • Hernandes Martins
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Apr 2011
    • 900

    #2
    Olá meu caro,

    Observe que o json que foi adicionando tem alguns erros, parece que tem um espaço no CurrentCount ("CurrentCoun t":0 , CurrentCoun t), fiz o ajuste manual e testei e funcionou.


    {
    "body":[
    {
    "Name":"CARRINHO",
    "CurrentCount":0,
    "LastCount":22,
    "Children":[

    ],
    "Performance":4.0
    },
    {
    "Name":"EFETIVA",
    "CurrentCoun t":0,
    "LastCount":8,
    "Children":[

    ],
    "Performance":12.0
    },
    {
    "Name":"CONFIRMA",
    "CurrentCo unt":0,
    "LastCount":1,
    "Children":[

    ],
    "Performance":100.0
    },
    {
    "Name":"ANULA",
    "CurrentCoun t":0,
    "LastCount":0,
    "Children":[

    ],
    "Performance":100.0
    }
    ]
    }





    JSONPath = $.body[3].CurrentCount

    Result:

    [
    0
    ]


    Abraços



    __

    Att.
    Hernandes Martins - Zabbix Trainer

    Zabbix Brazil Partner - www.luniobr.com

    Zabbix Brazil Community - www.zabbixbrasil.org

    Blog: hernandesmartins.blogspot.com.br

    Skype: hernandss
    Telegram: @MrHernandes

    Español
    Facebook: facebook.com/groups/zabbixlatam
    Telegram: https://t.me/ZabbixEspañol

    Português
    Facebook: facebook.com/groups/zabbixbrasil/
    Telegram: https://t.me/ZabbixBrasil

    Comment

    • Bruno Mazzo Feitosa
      Junior Member
      • Feb 2020
      • 4

      #3
      Obrigado pela ajuda, consegui aqui.

      Comment

      • diasdaniel
        Junior Member
        • Mar 2025
        • 1

        #4
        Olá,

        Estou tentando realizar o teste de leitura de json.
        Ao realizar o teste de forma individual obtenho sucesso.
        Porém ao realizar o teste de todas as etapas do Json a Solução zabbix não funciona como o esperado.

        English:

        I'm trying to perform the json reading test. When performing the test individually I am successful. However, when performing the test of all the json steps the zabbix solution does not work as expected.

        {"serverip":"127.0.0.1","message":"error"}

        Click image for larger version

Name:	image.png
Views:	40
Size:	49.6 KB
ID:	501091




        Click image for larger version

Name:	image.png
Views:	46
Size:	25.6 KB
ID:	501089


        Click image for larger version

Name:	image.png
Views:	39
Size:	50.9 KB
ID:	501090

        Comment

        • markfree
          Senior Member
          • Apr 2019
          • 868

          #5
          Originally posted by diasdaniel
          Olá,
          Estou tentando realizar o teste de leitura de json.
          Ao realizar o teste de forma individual obtenho sucesso.
          Porém ao realizar o teste de todas as etapas do Json a Solução zabbix não funciona como o esperado.
          Lembre-se que o pré-processamento é executado em sequência e o resultado de um step é a entrada do próximo.

          No seu exemplo, você está tentando executar 2 passos de JSONPath em sequência.
          Dessa forma, o resultado do primeiro passo será a string que representa um IP, e esse também será o valor avaliado pelo segundo passo.
          Assim, o segundo passo não consegue resolver o JSONPath, pois o valor deixou de ser um JSON.
          Para o item específico, você deve capturar ou o IP ou a mensagem.

          Penso que seria melhor criar 2 itens dependentes para este JSON, cada um com uma propriedade específica.
          Outra possibilidade seria criar um pré-processamento em Javascript que transforme este JSON em um formato mais amigável para, talvez, gerar um evento.

          Comment

          Working...