Ad Widget

Collapse

Discovery rules using HTTP agent problem

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Discovery rules using HTTP agent problem

    Hey guys,

    I'm trying to monitor my spot instances using Zabbix's discovery rules.
    I have a 4.2.0 server set up with a 4.2.0 agent on him.

    I tried 2 things:
    1. Sending the request directly through the discovery rule, setting it to HTTP agent, as a GET request type, with the correct headers and all.
    When enabled, the status of the discovery rule will be set to "Not Supported" with an error "Cannot find the 'data' array in the received JSON object".

    2. Setting up a regular item, HTTP Agent and GET request type, to get the text value from the request(tried with Convert to JSON on and off), then set up a discovery rule using dependent item on the master item.
    When enabled, the discovery rule returns the same error.

    In the documentation, it says:
    "Note that since Zabbix 4.2, the format of the JSON returned by low-level discovery rules has been changed. It is no longer expected that the JSON will contain the "data" object. Low-level discovery will now accept a normal JSON containing an array, in order to support new features such as the item value preprocessing and custom paths to low-level discovery macro values in a JSON document."

    The response I'm getting when sending this request manually is:
    {
    "request": {
    "id": "111111111111111111",
    "url": "/aws/ec2/group",
    "method": "GET",
    "timestamp": "2019-04-18T09:05:52.129Z"
    },
    "response": {
    "status": {
    "code": 200,
    "message": "OK"
    },
    "kind": "spotinst:aws:ec2:group",
    "items": [
    {
    "id": "sig-11111111111",
    "name": "Text-Text-6-servers",
    "description": "Text-6-servers",
    "capacity": {
    "minimum": 1,
    "maximum": 1,
    "target": 1,
    "unit": "instance"
    },
    And so on.

    Any ideas?

    #2
    It is required to preprocess discovery rule so that it would return array only.

    Comment


    • spctra
      spctra commented
      Editing a comment
      I have used preprocessing to extract only the "response" without the "request" part.
      The discovery rule is still failing on "data" array.

    #3
    Please provide more information on what has been extracted, exact jason would be perfect.

    Comment


    • spctra
      spctra commented
      Editing a comment
      So I set up an item and extracted only the reponse out of the JSON, the discovery rule still says it can't find the data array.
      This is the JSON response after the pre-processing(private data excluded):
      {
      "status": {
      "code": 200,
      "message": "OK"
      },
      "kind": "spotinst:aws:ec2:group",
      "items": [
      {
      "id": "sig-asdetra3w4",
      "name": "SARTS-ASDRTAS5.0",
      "description": "textextextex",
      "capacity": {
      "minimum": 0,
      "maximum": 2000,
      "target": 0,
      "unit": "instance"
      },
      "strategy": {
      "risk": 100,
      "onDemandCount": null,
      "availabilityVsCost": "balanced",
      "drainingTimeout": 120,
      "lifetimePeriod": "days",
      "fallbackToOd": true,
      "signals": [
      {
      "name": "INSTANCE_READY_TO_SHUTDOWN",
      "timeout": 200
      }
      ],
      "persistence": {},
      "revertToSpot": {
      "performAt": "never"
      }
      },
      "compute": {
      "instanceTypes": {
      "ondemand": "t2.large",
      "spot": [
      "t2.small",
      "t2.medium",
      "t2.large"
      ]
      },
      "availabilityZones": [
      {
      "name": "us-east-1a",
      "subnetIds": [
      "subnet-awe5awe5"
      ],
      "subnetId": "subnet-awe5awe5"
      },
      {
      "name": "us-east-1b",
      "subnetIds": [
      "subnet-awe5awe5"
      ],
      "subnetId": "subnet-awe5awe5"
      },
      {
      "name": "us-east-1d",
      "subnetIds": [
      "subnet-awe5wae5awe5"
      ],
      "subnetId": "subnet-awrawse54"
      },
      {
      "name": "us-east-1e",
      "subnetIds": [
      "subnet-awe5wea5"
      ],
      "subnetId": "subnet-523523wfg"
      }
      ],
      "product": "Linux/UNIX",
      "launchSpecification": {
      "loadBalancerNames": null,
      "loadBalancersConfig": {
      "loadBalancers": null
      },
      "healthCheckType": null,
      "securityGroupIds": [
      "sg-asd3123"
      ],
      "monitoring": false,
      "ebsOptimized": false,
      "imageId": "TEXTXETXET",
      "keyPair": "TEXT-TEXT-EXTT",
      "userData": "TEXTEXTEXTEXTXETXETEXTXETXETXETXETXET",
      "shutdownScript": "SFAfasgasdfASgasdhgaswh",
      "networkInterfaces": [
      {
      "deviceIndex": 0,
      "associatePublicIpAddress": true,
      "deleteOnTermination": true,
      "associateIpv6Address": false
      }
      ],
      "tags": [
      {
      "tagKey": "Name",
      "tagValue": "TEXTETXTEXTXTETX"
      },
      {
      "tagKey": "Role",
      "tagValue": "Render"
      },
      {
      "tagKey": "Env",
      "tagValue": "PreProd"
      },
      {
      "tagKey": "Elastigroup",
      "tagValue": "batch"
      }
      ],
      "tenancy": "default"
      }
      },
      "scaling": {},
      "scheduling": {},
      "thirdPartiesIntegration": {},
      "multai": null,
      "createdAt": "2018-07-16T07:24:06.000Z",
      "updatedAt": "2019-04-11T07:35:44.000Z"
      }
      ],
      "count": 1
      }

Announcement

Collapse
No announcement yet.
Working...
X