Skip to content
Snippets Groups Projects
Commit 00b9cf49 authored by Simon Crowle's avatar Simon Crowle
Browse files

Adds Apache2 alert rule and fixes Kapacitor.conf Slack endpoint

Also updates manual with instructions on how to configure Kapacitor (manually) so Slack messages are sent OK.
parent 1ffa34bc
No related branches found
No related tags found
No related merge requests found
......@@ -347,7 +347,7 @@ default-retention-policy = ""
# an Incoming Webhook integration.
# Visit https://slack.com/services/new/incoming-webhook
# to add new webhook for Kapacitor.
url = "https:\/\/hooks.slack.com\/services\/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"
url = "https://hooks.slack.com/services/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"
# Default channel for messages
channel = "#clmc"
# If true all the alerts will be sent to Slack
......
......@@ -38,7 +38,22 @@ The following command brings up the services
To automatically set up a demonstrator CLMC dashboard and Kapacitor, run the following:
### TO-DO: RE-FACTOR AUTOMATION FOR CONFIGURING KAPACITOR (kapacitor.conf)
Once Vagrant is finished, you will need to copy the kapacitor.conf file into clmc-service, then SSH in, configure Kapacitor and restart it:
```
# Copy the kapacitor.conf file in
vagrant plugin install vagrant-scp
vagrant scp ./test/streaming/kapacitor.conf clmc-service:/tmp/kapacitor.conf
# Configure and re-start kapacitor
vagrant --infra=streaming ssh clmc-service
sudo systemctl stop kapacitor
sudo mv /tmp/kapacitor.conf /etc/kapacitor/
sudo systemctl start kapacitor
exit
```
### Run the test set-up
```
cd ./test/streaming/
./setup.sh
......@@ -84,17 +99,19 @@ Press the Data Explorer in the menu and select the apache measurement and create
## KPI triggers
In this demonstrator an example KPI rule has been set up in Kapacitor which fires when the average requests per second on the Apache 1 server goes above certain thresholds ( a 'warning' at 0.2 requests/second and a 'critical' message at 0.5 requests/second ). The TICKscript specification for this rule is as follows:
In this demonstrator an example KPI rule has been set up in Kapacitor which fires when the average requests per second on the Apache 1 or Apache2 server goes above certain thresholds ( a 'warning' at 0.2 requests/second and a 'critical' message at 0.5 requests/second ). The TICKscript specification for this rule is as follows:
```
dbrp "CLMCMetrics"."autogen"
var data = batch
// Apache 1 rule
// -------------
var a1Data = batch
|query(''' SELECT mean("ReqPerSec") AS "mean_RPS" FROM "CLMCMetrics"."autogen"."apache" WHERE "ipendpoint"='adaptive_streaming_I1_apache1' ''')
.period(5s)
.every(5s)
var alert = data
var a1Alert = a1Data
|alert()
.id('{{ .Name }}/adaptive_streaming_I1_apache1')
.message('{{ .ID }} is {{ .Level }} Mean Requests Per Second: {{ index .Fields "mean_RPS" }}')
......@@ -102,6 +119,22 @@ var alert = data
.crit(lambda: "mean_RPS" > 0.5)
.slack()
.log( '/tmp/RPSLoad.log' )
// Apache 2 rule
// -------------
var a2Data = batch
|query(''' SELECT mean("ReqPerSec") AS "mean_RPS" FROM "CLMCMetrics"."autogen"."apache" WHERE "ipendpoint"='adaptive_streaming_I1_apache2' ''')
.period(5s)
.every(5s)
var a2Alert = a2Data
|alert()
.id('{{ .Name }}/adaptive_streaming_I1_apache2')
.message('{{ .ID }} is {{ .Level }} Mean Requests Per Second: {{ index .Fields "mean_RPS" }}')
.warn(lambda: "mean_RPS" > 0.2)
.crit(lambda: "mean_RPS" > 0.5)
.slack()
.log( '/tmp/RPSLoad.log' )
```
Alerts are sent both an internal logging within the CLMC service file system and also to a FLAME demo Slack service:
......
{
"id" : "Request_Rate_Alert",
"id" : "Request_Rate_Alert_ApacheServers",
"type" : "batch",
"dbrps" : [{"db": "CLMCMetrics", "rp" : "autogen"}],
"script" : "var data = batch\r\n |query(''' SELECT mean(\"ReqPerSec\") AS \"mean_RPS\" FROM \"CLMCMetrics\".\"autogen\".\"apache\" WHERE \"ipendpoint\"='adaptive_streaming_I1_apache1' ''')\r\n .period(5s)\r\n .every(5s)\r\n\r\nvar alert = data\r\n |alert()\r\n .id('{{ .Name }}\/adaptive_streaming_I1_apache1')\r\n .message('{{ .ID }} is {{ .Level }} Mean Requests Per Second: {{ index .Fields \"mean_RPS\" }}')\r\n .warn(lambda: \"mean_RPS\" > 0.2)\r\n .crit(lambda: \"mean_RPS\" > 0.5)\r\n .slack()\r\n .log( '\/tmp\/RPSLoad.log' )",
"script" : "\/\/ Apache 1 rule\r\n\/\/ -------------\r\nvar a1Data = batch\r\n |query(''' SELECT mean(\"ReqPerSec\") AS \"mean_RPS\" FROM \"CLMCMetrics\".\"autogen\".\"apache\" WHERE \"ipendpoint\"='adaptive_streaming_I1_apache1' ''')\r\n .period(5s)\r\n .every(5s)\r\n\r\nvar a1Alert = a1Data\r\n |alert()\r\n .id('{{ .Name }}\/adaptive_streaming_I1_apache1')\r\n .message('{{ .ID }} is {{ .Level }} Mean Requests Per Second: {{ index .Fields \"mean_RPS\" }}')\r\n .warn(lambda: \"mean_RPS\" > 0.2)\r\n .crit(lambda: \"mean_RPS\" > 0.5)\r\n .slack()\r\n .log( '\/tmp\/RPSLoad.log' )\r\n\r\n\/\/ Apache 2 rule\r\n\/\/ -------------\r\nvar a2Data = batch\r\n |query(''' SELECT mean(\"ReqPerSec\") AS \"mean_RPS\" FROM \"CLMCMetrics\".\"autogen\".\"apache\" WHERE \"ipendpoint\"='adaptive_streaming_I1_apache2' ''')\r\n .period(5s)\r\n .every(5s)\r\n\r\nvar a2Alert = a2Data\r\n |alert()\r\n .id('{{ .Name }}\/adaptive_streaming_I1_apache2')\r\n .message('{{ .ID }} is {{ .Level }} Mean Requests Per Second: {{ index .Fields \"mean_RPS\" }}')\r\n .warn(lambda: \"mean_RPS\" > 0.2)\r\n .crit(lambda: \"mean_RPS\" > 0.5)\r\n .slack()\r\n .log( '\/tmp\/RPSLoad.log' )",
"status" : "enabled"
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment