ike-dai / zaws

Zabbix AWS monitoring template
49 stars 27 forks source link

t3. ec2 instance metrics discovery #8

Open vti-uplata opened 5 years ago

vti-uplata commented 5 years ago

When i've tried to discover metrics for my t3.* instance, i've got this responce:

{"data":[{"{#METRIC.NAME}":"NetworkPacketsIn","{#METRIC.UNIT}":"Count","{#METRIC.NAMESPACE}":"AWS/EC2"},{"{#METRIC.NAME}":"EBSReadBytes","{#METRIC.UNIT}":"Bytes","{#METRIC.NAMESPACE}":"AWS/EC2"},{"{#METRIC.NAME}":"NetworkPacketsOut","{#METRIC.UNIT}":"Count","{#METRIC.NAMESPACE}":"AWS/EC2"},{"{#METRIC.NAME}":"EBSReadOps","{#METRIC.UNIT}":"Count","{#METRIC.NAMESPACE}":"AWS/EC2"},{"{#METRIC.NAME}":"CPUCreditUsage","{#METRIC.UNIT}":"Count","{#METRIC.NAMESPACE}":"AWS/EC2"},{"{#METRIC.NAME}":"EBSIOBalance%!"(MISSING),"{#METRIC.UNIT}":"Percent","{#METRIC.NAMESPACE}":"AWS/EC2"},{"{#METRIC.NAME}":"CPUSurplusCreditBalance","{#METRIC.UNIT}":"Count","{#METRIC.NAMESPACE}":"AWS/EC2"},{"{#METRIC.NAME}":"CPUCreditBalance","{#METRIC.UNIT}":"Count","{#METRIC.NAMESPACE}":"AWS/EC2"},{"{#METRIC.NAME}":"CPUUtilization","{#METRIC.UNIT}":"Percent","{#METRIC.NAMESPACE}":"AWS/EC2"},{"{#METRIC.NAME}":"EBSWriteOps","{#METRIC.UNIT}":"Count","{#METRIC.NAMESPACE}":"AWS/EC2"},{"{#METRIC.NAME}":"NetworkOut","{#METRIC.UNIT}":"Bytes","{#METRIC.NAMESPACE}":"AWS/EC2"},{"{#METRIC.NAME}":"StatusCheckFailed_Instance","{#METRIC.UNIT}":"Count","{#METRIC.NAMESPACE}":"AWS/EC2"},{"{#METRIC.NAME}":"NetworkIn","{#METRIC.UNIT}":"Bytes","{#METRIC.NAMESPACE}":"AWS/EC2"},{"{#METRIC.NAME}":"EBSWriteBytes","{#METRIC.UNIT}":"Bytes","{#METRIC.NAMESPACE}":"AWS/EC2"},{"{#METRIC.NAME}":"EBSByteBalance%!"(MISSING),"{#METRIC.UNIT}":"Percent","{#METRIC.NAMESPACE}":"AWS/EC2"},{"{#METRIC.NAME}":"CPUSurplusCreditsCharged","{#METRIC.UNIT}":"Count","{#METRIC.NAMESPACE}":"AWS/EC2"},{"{#METRIC.NAME}":"StatusCheckFailed_System","{#METRIC.UNIT}":"Count","{#METRIC.NAMESPACE}":"AWS/EC2"},{"{#METRIC.NAME}":"StatusCheckFailed","{#METRIC.UNIT}":"Count","{#METRIC.NAMESPACE}":"AWS/EC2"}]}

And that's not a valid JSON object (already confirmed that at https://jsonlint.com/), because there are two metrics with "broken" names:

"{#METRIC.NAME}": "EBSIOBalance%!"(MISSING), and "{#METRIC.NAME}": "EBSByteBalance%!"(MISSING),

It appears, that "(MISSING)" string breaks json format.

As i am not a programmer, but a jack-of-no-trades OPS, i have no knowledge how to fix that in source code. And suddenly an idea came into my mind - i can solve this with bash and sed like this:

  1. 've renamed zaws to zaws-bin
  2. 've created shell-script zaws with such content:

`#!/bin/bash

/usr/lib/zabbix/externalscripts/zaws-bin $@ | sed -e "s|(MISSING)||g"`

So, if anyone can fix this issue in source code and build new binary - it would be awesome.