Ad Widget

Collapse

Using JSONPath to extract top level value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • high-t
    Member
    • Dec 2014
    • 68

    #1

    Using JSONPath to extract top level value

    Hi.

    I have the following JSON:
    Code:
    {
    "_nodes" : {
    "total" : 7,
    "successful" : 7,
    "failed" : 0
    },
    "cluster_name" : "test",
    "nodes" : {
    [COLOR=#1abc9c][B]"nrVmgb-0Q_y_3OHK3xlpOw[/B][/COLOR]" : {
    "name" : "ip-10-0-5-74",
    "transport_address" : "10.0.5.74:9300",
    "host" : "10.0.5.74",
    "ip" : "10.0.5.74",
    "version" : "7.6.2",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "ef48eb35cf30adf4db14086e8aabd07ef6fb113f",
    "roles" : [
    "master",
    "ml"
    ],
    "attributes" : {
    "aws_availability_zone" : "eu-west-1b",
    "ml.machine_memory" : "8039129088",
    "ml.max_open_jobs" : "20",
    "xpack.installed" : "true"
    },
    "process" : {
    "refresh_interval_in_millis" : 1000,
    "id" : 1239,
    "mlockall" : false
    }
    },
    "[B][COLOR=#1abc9c]0yUVhjZLRXGhsY6dMsrwoQ[/COLOR][/B]" : {
    "name" : "ip-10-0-4-211",
    "transport_address" : "10.0.4.211:9300",
    "host" : "10.0.4.211",
    "ip" : "10.0.4.211",
    "version" : "7.6.2",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "ef48eb35cf30adf4db14086e8aabd07ef6fb113f",
    "roles" : [
    "master",
    "ml"
    ],
    "attributes" : {
    "aws_availability_zone" : "eu-west-1a",
    "ml.machine_memory" : "8039129088",
    "ml.max_open_jobs" : "20",
    "xpack.installed" : "true"
    },
    "process" : {
    "refresh_interval_in_millis" : 1000,
    "id" : 1235,
    "mlockall" : false
    }
    },
    "[B][COLOR=#1abc9c]pnMU-zZGQ6GQtanhC4JLvg[/COLOR][/B]" : {
    "name" : "ip-10-0-4-112",
    "transport_address" : "10.0.4.112:9300",
    "host" : "10.0.4.112",
    "ip" : "10.0.4.112",
    "version" : "7.6.2",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "ef48eb35cf30adf4db14086e8aabd07ef6fb113f",
    "roles" : [
    "ml"
    ],
    "attributes" : {
    "aws_availability_zone" : "eu-west-1a",
    "ml.machine_memory" : "8039120896",
    "ml.max_open_jobs" : "20",
    "xpack.installed" : "true"
    },
    "process" : {
    "refresh_interval_in_millis" : 1000,
    "id" : 974,
    "mlockall" : false
    }
    },
    "[B][COLOR=#1abc9c]ivWth8BRQAKssrvms_fbVA[/COLOR][/B]" : {
    "name" : "ip-10-0-4-182",
    "transport_address" : "10.0.4.182:9300",
    "host" : "10.0.4.182",
    "ip" : "10.0.4.182",
    "version" : "7.6.2",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "ef48eb35cf30adf4db14086e8aabd07ef6fb113f",
    "roles" : [
    "ingest",
    "data",
    "ml"
    ],
    "attributes" : {
    "aws_availability_zone" : "eu-west-1a",
    "ml.machine_memory" : "66610987008",
    "xpack.installed" : "true",
    "ml.max_open_jobs" : "20"
    },
    "process" : {
    "refresh_interval_in_millis" : 1000,
    "id" : 953,
    "mlockall" : false
    }
    },
    "[COLOR=#1abc9c][B]d_G-IHcyTDmMubaRGQBJNw[/B][/COLOR]" : {
    "name" : "ip-10-0-4-177",
    "transport_address" : "10.0.4.177:9300",
    "host" : "10.0.4.177",
    "ip" : "10.0.4.177",
    "version" : "7.6.2",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "ef48eb35cf30adf4db14086e8aabd07ef6fb113f",
    "roles" : [
    "ingest",
    "data",
    "ml"
    ],
    "attributes" : {
    "aws_availability_zone" : "eu-west-1a",
    "ml.machine_memory" : "66611220480",
    "ml.max_open_jobs" : "20",
    "xpack.installed" : "true"
    },
    "process" : {
    "refresh_interval_in_millis" : 1000,
    "id" : 1048,
    "mlockall" : false
    }
    },
    "[COLOR=#1abc9c][B]kubJAhycQAGsSjg2LEcmkQ[/B][/COLOR]" : {
    "name" : "ip-10-0-4-89",
    "transport_address" : "10.0.4.89:9300",
    "host" : "10.0.4.89",
    "ip" : "10.0.4.89",
    "version" : "7.6.2",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "ef48eb35cf30adf4db14086e8aabd07ef6fb113f",
    "roles" : [
    "master",
    "ml"
    ],
    "attributes" : {
    "aws_availability_zone" : "eu-west-1a",
    "ml.machine_memory" : "8039129088",
    "ml.max_open_jobs" : "20",
    "xpack.installed" : "true"
    },
    "process" : {
    "refresh_interval_in_millis" : 1000,
    "id" : 1301,
    "mlockall" : false
    }
    },
    "[B][COLOR=#1abc9c]JWUBjjPSS56Xp19vHfJpNQ[/COLOR][/B]" : {
    "name" : "ip-10-0-5-192",
    "transport_address" : "10.0.5.192:9300",
    "host" : "10.0.5.192",
    "ip" : "10.0.5.192",
    "version" : "7.6.2",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "ef48eb35cf30adf4db14086e8aabd07ef6fb113f",
    "roles" : [
    "ingest",
    "data",
    "ml"
    ],
    "attributes" : {
    "aws_availability_zone" : "eu-west-1b",
    "ml.machine_memory" : "66714599424",
    "ml.max_open_jobs" : "20",
    "xpack.installed" : "true"
    },
    "process" : {
    "refresh_interval_in_millis" : 1000,
    "id" : 1109,
    "mlockall" : false
    }
    }
    }
    }
    I'm trying to use JSONpath to extract a list of nodes IDs (marked bold in blue).
    I'm quite lost at this point. Will appreciate any help...
    Thank you!
    Amit.
  • Semiadmin
    Senior Member
    • Oct 2014
    • 1625

    #2
    Hi!
    $.nodes[*]~
    Zabbix 4.4.7 and above

    Comment

    • high-t
      Member
      • Dec 2014
      • 68

      #3
      Thank you, Semiadmin . Appreciated.

      Comment

      Working...