prometheus support & shell scripts integration with netdata #1504

Merged
merged 11 commits into from Jan 5, 2017

Projects

None yet

1 participant

@ktsaou
Member
ktsaou commented Jan 3, 2017 edited

prometheus

fixes #1497

Prometheus is polling for data. This PR adds a new API method to netdata /api/v1/allmetrics?format=prometheus.

This call returns the latest collected values for all metrics collected by netdata.

shell

Now shell scripts can run:

eval "$(curl -s 'http://localhost:19999/api/v1/allmetrics')"

after this command, all the netdata metrics are exposed to shell. Check:

# source the metrics
eval "$(curl -s 'http://localhost:19999/api/v1/allmetrics')"

# let's see if there are variables exposed by netdata for system.cpu
set | grep "^NETDATA_SYSTEM_CPU"

NETDATA_SYSTEM_CPU_GUEST=0
NETDATA_SYSTEM_CPU_GUEST_NICE=0
NETDATA_SYSTEM_CPU_IDLE=95
NETDATA_SYSTEM_CPU_IOWAIT=0
NETDATA_SYSTEM_CPU_IRQ=0
NETDATA_SYSTEM_CPU_NICE=0
NETDATA_SYSTEM_CPU_SOFTIRQ=0
NETDATA_SYSTEM_CPU_STEAL=0
NETDATA_SYSTEM_CPU_SYSTEM=1
NETDATA_SYSTEM_CPU_USER=4
NETDATA_SYSTEM_CPU_VISIBLETOTAL=5

# let's see the total cpu utilization of the system
echo ${NETDATA_SYSTEM_CPU_VISIBLETOTAL}
5

# what about alarms?
set | grep "^NETDATA_ALARM_SYSTEM_SWAP_"
NETDATA_ALARM_SYSTEM_SWAP_RAM_IN_SWAP_STATUS=CRITICAL
NETDATA_ALARM_SYSTEM_SWAP_RAM_IN_SWAP_VALUE=53
NETDATA_ALARM_SYSTEM_SWAP_USED_SWAP_STATUS=CLEAR
NETDATA_ALARM_SYSTEM_SWAP_USED_SWAP_VALUE=51

# let's get the current status of the alarm 'ram in swap'
echo ${NETDATA_ALARM_SYSTEM_SWAP_RAM_IN_SWAP_STATUS}
CRITICAL

# is it fast?
time curl -s 'http://localhost:19999/api/v1/allmetrics' >/dev/null

real	0m0,070s
user	0m0,000s
sys	0m0,007s

# it is... 0.07 seconds for curl to be loaded, connect to netdata and fetch the response back...

The _VISIBLETOTAL variable sums up all the dimensions of each chart.

The format of the variables is:

NETDATA_${chart_id^^}_${dimension_id^^}="${value}"

The value is rounded to the closest integer, since shell script cannot process decimal numbers.

ktsaou added some commits Jan 3, 2017
@ktsaou ktsaou add prometheus support to the API; fixes #1497 e756f1e
@ktsaou ktsaou updated prometheus support according to #1497 e76ac88
@ktsaou ktsaou remove all dots from prometheus names; #1497 304dc3e
@ktsaou ktsaou fixed a memory leak in cgroups periodic update job db4dc8c
@ktsaou ktsaou added SHELL support for allmetrics all call fd1c617
@ktsaou ktsaou added allmetrics call to swagger dace858
@ktsaou ktsaou changed the title from prometheus supports to prometheus & shell supports Jan 3, 2017
@ktsaou ktsaou added the VISIBLETOTAL variable and fixed the error message about an …
…invalid format being requested
aa49687
@ktsaou ktsaou changed the title from prometheus & shell supports to prometheus support & shell scripts integration with netdata Jan 3, 2017
ktsaou added some commits Jan 3, 2017
@ktsaou ktsaou expose netdata alarms in allmetrics for shell 1c66376
@ktsaou ktsaou avoid web browser layout trashing when the dashboard is loaded; gaine…
…d 500ms to 1000ms when loading the dashboard
b3b4d7a
@ktsaou ktsaou more work on preventing web browser layout trashing on loading 0e9a658
@ktsaou ktsaou layout trashing prevention is problematic on IE and safari - the disp…
…lay is out of sync; removing it again
e60a258
@ktsaou ktsaou merged commit db45632 into firehol:master Jan 5, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment