Ad Widget

Collapse

JSON-over-HTTP LLD fails with name contains invalid character '{'

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • viktorkho
    Member
    • Jul 2013
    • 90

    #1

    JSON-over-HTTP LLD fails with name contains invalid character '{'

    I'm trying to configure a simple Host LLD from JSON over HTTP source, like this one: https://pastebin.com/raw/YWWxGs7y

    It uses Preprocessing step with JSONpath (I can test it with built-in testing tool) and 3 LLD-macros which are JSONPaths, too. I test them with output (Result) JSON from built-in testing tool and https://jsonpath.com/

    My LLD fails with multiple errors:
    Code:
    Cannot create host "{#LOCATION_ID}": name contains invalid character '{'.
    Cannot create host "{#LOCATION_ID}": name contains invalid character '{'.
    Cannot create host "{#LOCATION_ID}": name contains invalid character '{'.
    Cannot create host "{#LOCATION_ID}": name contains invalid character '{'.​
    ...
    I guess that LLD-Macro's value remains empty, but I have no idea how to check and solve this

    My Template (how can I attach a file?)

    Code:
    zabbix_export:
      version: '6.2'
      date: '2023-02-15T14:20:24Z'
      template_groups:
        -
          uuid: ea8da0a2b67548b2984e3db9e32283e3
          name: Test
      host_groups:
        -
          uuid: fe9787f6bc204ac6bd6cffff87c90502
          name: Delete
      templates:
        -
          uuid: 5c223d99b28a48faa12e30f486a73fe4
          template: 'JSON over HTTP LLD Test'
          name: 'JSON over HTTP LLD Test'
          groups:
            -
              name: Test
          discovery_rules:
            -
              uuid: f931ee3db784403ea9d54edbb653f37a
              name: Test
              type: HTTP_AGENT
              key: json_over_http
              host_prototypes:
                -
                  uuid: a01ddbdef5704097a89ff4a36001d331
                  host: '{#LOCATION_ID}'
                  name: '{#LOCATION_TYPE} {#LOCATION_NAME}'
                  group_links:
                    -
                      group:
                        name: Delete
              url: 'https://pastebin.com/raw/YWWxGs7y'
              lld_macro_paths:
                -
                  lld_macro: '{#LOCATION_ID}'
                  path: '$.[*].id'
                -
                  lld_macro: '{#LOCATION_NAME}'
                  path: '$.[*].name'
                -
                  lld_macro: '{#LOCATION_TYPE}'
                  path: '$.[*].type'
              preprocessing:
                -
                  type: JSONPATH
                  parameters:
                    - $.items
    
    ​



  • viktorkho
    Member
    • Jul 2013
    • 90

    #2
    Solved on Stackoverflow. Proper LLD Macro's JSONpaths are:
    Code:
    lld_macro_paths:
    -
    lld_macro: '{#LOCATION_ID}'
    path: '$.id'
    -
    lld_macro: '{#LOCATION_NAME}'
    path: '$.name'
    -
    lld_macro: '{#LOCATION_TYPE}'
    path: '$.type'​









    Comment

    • cyber
      Senior Member
      Zabbix Certified SpecialistZabbix Certified Professional
      • Dec 2006
      • 4807

      #3
      There is a jsonpath online parser.. https://www.javainuse.com/jsonpath (maybe some others also). These help you to test out your things.

      Comment

      Working...