]> git.openstreetmap.org Git - chef.git/commitdiff
Configure cloudwatch exporter to collect S3 metrics
authorTom Hughes <tom@compton.nu>
Tue, 10 Oct 2023 23:32:12 +0000 (00:32 +0100)
committerTom Hughes <tom@compton.nu>
Tue, 10 Oct 2023 23:38:58 +0000 (00:38 +0100)
cookbooks/prometheus/recipes/server.rb
cookbooks/prometheus/templates/default/cloudwatch.yml.erb [new file with mode: 0644]

index 45550368cd5b669f1cb1b49ee9c1159fccbdb4d1..1a6639abea6d5a7ee995368f39d3318642ad4951 100644 (file)
@@ -44,6 +44,22 @@ prometheus_exporter "statuscake" do
   environment "STATUSCAKE_APIKEY" => tokens["statuscake"]
 end
 
+template "/etc/prometheus/cloudwatch.yml" do
+  source "cloudwatch.yml.erb"
+  owner "root"
+  group "root"
+  mode "644"
+end
+
+prometheus_exporter "cloudwatch" do
+  address "127.0.0.1"
+  port 5000
+  listen_switch "listen-address"
+  options "--config.file=/etc/prometheus/cloudwatch.yml"
+  environment "AWS_ACCESS_KEY_ID" => "AKIASQUXHPE7JHG37EA6",
+              "AWS_SECRET_ACCESS_KEY" => tokens["cloudwatch"]
+end
+
 cache_dir = Chef::Config[:file_cache_path]
 
 prometheus_version = "2.45.0"
diff --git a/cookbooks/prometheus/templates/default/cloudwatch.yml.erb b/cookbooks/prometheus/templates/default/cloudwatch.yml.erb
new file mode 100644 (file)
index 0000000..73659af
--- /dev/null
@@ -0,0 +1,50 @@
+apiVersion: v1alpha1
+discovery:
+  jobs:
+    - type: AWS/S3
+      regions:
+        - eu-west-1
+        - eu-west-2
+      roles:
+        - roleArn: "arn:aws:iam::173189593406:role/osm-cloudwatch-export-role"
+      period: 300
+      length: 300
+      metrics:
+        - name: BucketSizeBytes
+          statistics: [Average]
+        - name: NumberOfObjects
+          statistics: [Average]
+        - name: AllRequests
+          statistics: [Sum]
+        - name: GetRequests
+          statistics: [Sum]
+        - name: PutRequests
+          statistics: [Sum]
+        - name: DeleteRequests
+          statistics: [Sum]
+        - name: HeadRequests
+          statistics: [Sum]
+        - name: PostRequests
+          statistics: [Sum]
+        - name: ListRequests
+          statistics: [Sum]
+        - name: BytesDownloaded
+          statistics: [Sum]
+        - name: BytesUploaded
+          statistics: [Sum]
+        - name: 4xxErrors
+          statistics: [Sum]
+        - name: 5xxErrors
+          statistics: [Sum]
+        - name: FirstByteLatency
+          statistics: [Minimum, Maximum, Average]
+        - name: TotalRequestLatency
+          statistics: [Minimum, Maximum, Average]
+        - name: ReplicationLatency
+          statistics: [Maximum]
+        - name: BytesPendingReplication
+          statistics: [Maximum]
+        - name: OperationsPendingReplication
+          statistics: [Maximum]
+        - name: OperationsFailedReplication
+          statistics: [Sum]