Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Metrics improvements (#2280)

Rich Turner97339d3a49ad
diff --git a/.ci_cd/aws/cloudformation-create-dashboard.yml b/.ci_cd/aws/cloudformation-create-dashboard.yml
index 614eb656e..c3cd41850 100644
--- a/.ci_cd/aws/cloudformation-create-dashboard.yml
+++ b/.ci_cd/aws/cloudformation-create-dashboard.yml
@@ -13,24 +13,24 @@ Resources:
{
"variables": [
{
- "type": "property",
- "property": "InstanceName",
- "inputType": "select",
- "id": "InstanceName",
- "label": "Instance",
- "visible": true,
- "search": "CWAgent-Prometheus MetricName=or_attributes_total",
- "populateFrom": "InstanceName"
+ "type": "property",
+ "property": "InstanceName",
+ "inputType": "select",
+ "id": "InstanceName",
+ "label": "Instance",
+ "visible": true,
+ "search": "CWAgent-Prometheus MetricName=or_attributes_total",
+ "populateFrom": "InstanceName"
},
{
- "type": "property",
- "property": "InstanceId",
- "inputType": "select",
- "id": "InstanceId",
- "label": "EC2 Instance ID",
- "visible": true,
- "search": "CWAgent MetricName=disk_used_percent",
- "populateFrom": "InstanceId"
+ "type": "property",
+ "property": "InstanceId",
+ "inputType": "select",
+ "id": "InstanceId",
+ "label": "EC2 Instance ID",
+ "visible": true,
+ "search": "CWAgent MetricName=disk_used_percent",
+ "populateFrom": "InstanceId"
}
],
"widgets": [
@@ -42,12 +42,15 @@ Resources:
"type": "metric",
"properties": {
"metrics": [
+ [ { "expression": "m8-m6-m5-m4-m3-m2-m1", "label": "Other", "id": "e1", "region": "eu-west-1" } ],
[ "CWAgent-Prometheus", "or_attributes_total", "InstanceName", "a", "source", "RulesEngine", { "id": "m1", "yAxis": "left", "label": "Rules" } ],
- [ "...", "AgentService", { "id": "m3", "yAxis": "left", "label": "Agents" } ],
[ "...", "DefaultMQTTHandler", { "id": "m2", "yAxis": "left", "label": "MQTT" } ],
+ [ "...", "AgentService", { "id": "m3", "yAxis": "left", "label": "Agents" } ],
[ "...", "AssetResource", { "id": "m4", "yAxis": "left", "label": "HTTP API" } ],
[ "...", "WebsocketClient", { "id": "m5", "yAxis": "left", "label": "Websocket" } ],
- [ ".", "artemis_message_count", ".", ".", "queue", "*.*.writeattributevalue.#", { "id": "m6", "yAxis": "left", "label": "MQTT Backlog" } ]
+ [ "...", "GatewayService", { "id": "m6", "yAxis": "left", "label": "Gateways" } ],
+ [ ".", "artemis_message_count", ".", ".", "queue", "*.*.writeattributevalue.#", { "id": "m7", "yAxis": "left", "label": "MQTT Backlog" } ],
+ [ ".", "or_attributes_seconds_count", ".", ".", { "visible": false, "label": "Total", "id": "m8" } ]
],
"view": "timeSeries",
"stacked": false,
@@ -92,9 +95,9 @@ Resources:
"min": 0
},
"right": {
- "showUnits": false,
- "label": "ms",
- "min": 0
+ "showUnits": false,
+ "label": "ms",
+ "min": 0
}
}
}
diff --git a/.ci_cd/aws/cloudformation-create-ec2.yml b/.ci_cd/aws/cloudformation-create-ec2.yml
index b10d34ddd..8bb669675 100644
--- a/.ci_cd/aws/cloudformation-create-ec2.yml
+++ b/.ci_cd/aws/cloudformation-create-ec2.yml
@@ -343,7 +343,7 @@ Resources:
},
{
"source_labels": [ "job", "source" ],
- "label_matcher": "manager;(RulesEngine|AgentService|DefaultMQTTHandler|AssetResource|WebsocketClient)",
+ "label_matcher": "manager;.*",
"dimensions": [
[ "InstanceName", "source" ]
],
@@ -1111,3 +1111,41 @@ Resources:
- !Ref SnsTopic
OKActions:
- !Ref SnsTopic
+
+ AttributeEventAnomalyDetector:
+ Type: AWS::CloudWatch::AnomalyDetector
+ Condition: MetricsEnabled
+ Properties:
+ Namespace: CWAgent-Prometheus
+ MetricName: or_attributes_seconds_count
+ Stat: Average
+ Dimensions:
+ - Name: InstanceName
+ Value: !Ref Host
+
+ AttributeEventAlarm:
+ Type: AWS::CloudWatch::Alarm
+ Condition: MetricsEnabled
+ Properties:
+ AlarmDescription: Attribute event anomaly
+ ComparisonOperator: LessThanLowerOrGreaterThanUpperThreshold
+ EvaluationPeriods: 1
+ Metrics:
+ - Expression: ANOMALY_DETECTION_BAND(m1, 2)
+ Id: ad1
+ - Id: m1
+ MetricStat:
+ Metric:
+ MetricName: or_attributes_seconds_count
+ Namespace: CWAgent-Prometheus
+ Dimensions:
+ - Name: InstanceName
+ Value: !Ref Host
+ Period: 300
+ Stat: Average
+ ThresholdMetricId: ad1
+ TreatMissingData: breaching
+ AlarmActions:
+ - !Ref SnsTopic
+ OKActions:
+ - !Ref SnsTopic