Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sauravvishal8797/7209bdcbbcb899854a1d468bdb437fd7 to your computer and use it in GitHub Desktop.
Save sauravvishal8797/7209bdcbbcb899854a1d468bdb437fd7 to your computer and use it in GitHub Desktop.
Will start with injecting the metrics data into the Hawkular server (adding of new metrics could be another good idea here which could increase the user-friendliness of the project with users). This can be done easily with the use of Curl command with the metrics REST api provided by the project. For instance I can use cpu load metrics data of an operating system(to send to the server). I could use the stats for smaller intervals of time and store it in a json file(cpu_load.json)
Will send the data to the hawkular server using the post
Curl command.
Now I will check the data by setting up Grafana and its Hawkular plugin to actually build a dashboard and look at the cpu_json(cpu load metrics) for that period of time. It would look something like the one shown below.
Will be adding alerting to be notified for particular conditions(here it will notify when the CPU load exceeds the provided alerting condition) which will trigger the alert/event when the conditions are met. Will be adding some additional metadata including severity, and a short description. Now I will put everything in a single json file like one below whereas in practice the actions can be separated as they are reusable among various triggers. Here I have kept the action plugin to email so the administrator/maintainer will be notified
with an email when the alert is triggered.
To import that trigger definition I will be using the import command of the REST API
Curl -u jdoe:password -X POST http://livingontheedge.hawkular.org/hawkular/
alerts/import/all -d @includes/alert-definition.json -H "Content-Type: application/json" -H "Hawkular-Tenant: Hawkular"
Time for testing the alert trigger created, I will enter metrics data in a json file where I will be having some values that will satisfy the conditions for the alerts
to be triggered and an email would be send to the administrator/maintainer about the cpu-load being crossing the threshold. I will be entering more metrics similar to
what I did earlier. The metrics is stored in the file cpu_load_test.json.
Will execute the Curl command to store the metrics and it will evaluate against our Alert trigger conditions.
curl -u jdoe:password -X POST http://http://livingontheedge.hawkular.org/hawkular/
metrics/gauges/cpu_load/raw -d cpu_load_test.json -Type: application/json -H
"Hawkular-Tenant: Hawkular"
Now when we check the logs of the Hawkular-services, we will be able to see 1 INFO message showing that the conditions were met such as here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment