From: Tom Hughes Date: Tue, 10 Oct 2023 23:32:12 +0000 (+0100) Subject: Configure cloudwatch exporter to collect S3 metrics X-Git-Url: https://git.openstreetmap.org/chef.git/commitdiff_plain/65d913a7f1b116d8e53cfcc70973ec8bb467ab76 Configure cloudwatch exporter to collect S3 metrics --- diff --git a/cookbooks/prometheus/recipes/server.rb b/cookbooks/prometheus/recipes/server.rb index 45550368c..1a6639abe 100644 --- a/cookbooks/prometheus/recipes/server.rb +++ b/cookbooks/prometheus/recipes/server.rb @@ -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 index 000000000..73659af7c --- /dev/null +++ b/cookbooks/prometheus/templates/default/cloudwatch.yml.erb @@ -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]