Skip to content

Instantly share code, notes, and snippets.

@pavolloffay
Last active January 13, 2016 15:26
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 pavolloffay/8d446a979a858d7c6944 to your computer and use it in GitHub Desktop.
Save pavolloffay/8d446a979a858d7c6944 to your computer and use it in GitHub Desktop.
Hawkular datamining + Alerts
tenant=$(curl -s GET 'http://jdoe:password@localhost:8080/hawkular/inventory/tenant'| grep --color=never -oP 'id" : "\K[0-9a-z\-]+')
feed=$(curl -s GET 'http://jdoe:password@localhost:8080/hawkular/inventory/feeds'| grep --color=never -oP 'id" : "\K[0-9a-z\-]+')
function feed() {
echo `curl -s GET 'http://jdoe:password@localhost:8080/hawkular/inventory/feeds'| grep --color=never -oP 'id" : "\K[0-9a-z\-]+'`
}
function tenant() {
echo `curl -s GET 'http://jdoe:password@localhost:8080/hawkular/inventory/tenant'| grep --color=never -oP 'id" : "\K[0-9a-z\-]+'`
}
curl -ivX GET 'http://jdoe:password@localhost:8080/hawkular/inventory/test/metrics' > out
curl -X GET 'http://jdoe:password@localhost:8080/hawkular/alerts/' | jq ''
curl -X GET 'http://jdoe:password@localhost:8080/hawkular/alerts/triggers' | jq ''
curl -X GET -H 'Content-Type: application/json' 'http://jdoe:password@localhost:8080/hawkular/alerts/triggers/predictionHeapUsed' | jq ''
curl -X GET 'http://jdoe:password@localhost:8080/hawkular/alerts/triggers/d5dfbbe9-eaeb-4a3d-8ab1-c8d8b635c39d%2FLocal_jvm_pheap/conditions' | jq '.'
#Trigger
curl -ivX POST -H 'Content-Type: application/json' 'http://jdoe:password@localhost:8080/hawkular/alerts/triggers' -d '{
"id": "predictionHeapUsed",
"enabled": "true",
"name": "Prediction Java Heap Used",
"description": "Prediction of Java Heap Used metric",
"severity": "HIGH",
"context": {
"triggerType": "Threshold",
"resourceType": "App Server",
"resourcePath": "/t;'`tenant`'/f;'`feed`'/r;Local~~",
"resourceName": "'`feed`'/Local",
"alertType": "PHEAP"
},
"tags": {
"resourceId": "'`feed`'/Local"
},
"actions": {
"email": [
"jdoe@acme.com"
]
}
}'
curl -ivX PUT -H 'Content-Type: application/json' 'http://jdoe:password@localhost:8080/hawkular/alerts/triggers/predictionHeapUsed' -d '{
"enabled": "true",
"name": "Prediction Java Heap Used",
"description": "Prediction of Java Heap Used metric",
"severity": "HIGH",
"context": {
"triggerType": "Threshold",
"resourceType": "App Server",
"resourcePath": "/t;'`tenant`'/f;'`feed`'/r;Local~~",
"resourceName": "'`feed`'/Local",
"alertType": "PHEAP"
},
"tags": {
"resourceId": "'`feed`'/Local"
},
"actions": {
"email": [
"jdoe@acme.com"
]
}
}'
# Conditions
curl -ivX POST -H 'Content-Type:application/json' 'http://jdoe:password@localhost:8080/hawkular/alerts/triggers/predictionHeapUsed/conditions' -d '{
"type": "threshold",
"dataId": "prediction_MI~R~['feed'/Local~~]~MT~WildFly Memory Metrics~Heap Used",
"threshold": 10,
"operator": "GT"
}'
# Dampening
curl -ivX POST -H 'Content-Type: application/json' 'http://jdoe:password@localhost:8080/hawkular/alerts/triggers/predictionHeapUsed/dampenings' -d '{
"evalTimeSetting": 0,
"evalTotalSetting": 1,
"evalTrueSetting": 1
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment