### Example Configuration File Source: https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/docs/configuration.md This is a complete example of a configuration file for the exporter, demonstrating how to define custom namespaces and metrics. ```yaml apiVersion: v1alpha1 sts-region: eu-west-1 customNamespace: - name: customEC2Metrics namespace: CustomEC2Metrics regions: - us-east-1 metrics: - name: cpu_usage_idle statistics: - Average period: 300 length: 300 nilToZero: true - name: disk_free statistics: - Average period: 300 length: 300 nilToZero: true ``` -------------------------------- ### Install jsonnet-bundler Source: https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/mixin/README.md Installs the jsonnet-bundler tool, which is required for managing mixin dependencies. Ensure Go is installed and configured. ```bash go install -a github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb@latest ``` -------------------------------- ### Example Kafka Job Configuration Source: https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/docs/configuration.md This example demonstrates how to configure a Kafka job, specifying regions, search tags, and metrics to collect. ```yaml apiVersion: v1alpha1 sts-region: eu-west-1 discovery: exportedTagsOnMetrics: kafka: - Name jobs: - type: kafka regions: - eu-west-1 searchTags: - key: env value: dev metrics: - name: BytesOutPerSec statistics: - Average period: 600 length: 600 ``` -------------------------------- ### Metrics Examples Source: https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/README.md Examples of metrics exported by YACE, including those with exported tags and info helpers. ```text ### Metrics with exportedTagsOnMetrics aws_ec2_cpuutilization_maximum{dimension_InstanceId="i-someid", name="arn:aws:ec2:eu-west-1:472724724:instance/i-someid", tag_Name="jenkins"} 57.2916666666667 ### Info helper with tags aws_elb_info{name="arn:aws:elasticloadbalancing:eu-west-1:472724724:loadbalancer/a815b16g3417211e7738a02fcc13bbf9",tag_KubernetesCluster="production-19",tag_Name="",tag_kubernetes_io_cluster_production_19="owned",tag_kubernetes_io_service_name="nginx-ingress/private-ext",region="eu-west-1"} 0 aws_ec2_info{name="arn:aws:ec2:eu-west-1:472724724:instance/i-someid",tag_Name="jenkins"} 0 ### Track cloudwatch requests to calculate costs yace_cloudwatch_requests_total 168 ``` -------------------------------- ### Exported Tags Configuration Example Source: https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/docs/configuration.md This example demonstrates how to configure tags to be exported along with metrics for specific AWS resources. ```yaml exportedTagsOnMetrics: ebs: - VolumeId kafka: - Name ``` -------------------------------- ### Example Static Job Configuration Source: https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/docs/configuration.md This example shows a static job configuration for AWS/AutoScaling, including dimensions, custom tags, and specific metrics. ```yaml apiVersion: v1alpha1 sts-region: eu-west-1 static: - namespace: AWS/AutoScaling name: must_be_set regions: - eu-west-1 dimensions: - name: AutoScalingGroupName value: MyGroup customTags: - key: CustomTag value: CustomValue metrics: - name: GroupInServiceInstances statistics: - Minimum period: 60 length: 300 ``` -------------------------------- ### Query Example without exportedTagsOnMetrics Source: https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/README.md An example PromQL query demonstrating how to join CPU utilization with instance information using the 'name' tag when tags are not exported directly on metrics. ```text # CPUUtilization + Name tag of the instance id - No more instance id needed for monitoring aws_ec2_cpuutilization_average + on (name) group_left(tag_Name) aws_ec2_info ``` -------------------------------- ### Build and Start Docker Compose Environment Source: https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/docker-compose/README.md Builds the YACE Docker image and then starts all services defined in the docker-compose configuration. Specify AWS_REGION and AWS_PROFILE to configure YACE's AWS credentials. ```bash # Build the YACE docker image docker-compose build ``` ```bash # Start all docker-compose resource AWS_REGION=us-east-1 AWS_PROFILE=sandbox docker-compose up -d ``` -------------------------------- ### Install Mixin Dependencies Source: https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/mixin/README.md Installs all the dependencies required by the CloudWatch Mixin using jsonnet-bundler. This command should be run in the root directory of the mixin. ```bash jb install ``` -------------------------------- ### Metric Configuration Example Source: https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/docs/configuration.md This snippet shows how to define a specific metric configuration, overriding general job-level settings. ```yaml # CloudWatch metric name name: # List of statistic types, e.g. "Minimum", "Maximum", etc. (Overrides job level setting) statistics: [ - ... ] # Statistic period in seconds (Overrides job level setting) [ period: ] # How far back to request data for in seconds (Overrides job level setting) [ length: ] # If set it will request metrics up until `current_time - delay` (Overrides job level setting) [ delay: ] # Return 0 value if Cloudwatch returns no metrics at all. By default `NaN` will be reported (Overrides job level setting) [ nilToZero: ] # Export the metric with the original CloudWatch timestamp (Overrides job level setting) [ addCloudwatchTimestamp: ] # Enables the inclusion of past metric data points from the CloudWatch response if available. # This is useful when a metric is configured with a 60-second period and a 300-second duration, ensuring that all # five data points are exposed at the metrics endpoint instead of only the latest one. # Note: This option requires `addCloudwatchTimestamp` to be enabled. # The metric destination must support out of order timestamps, see https://prometheus.io/docs/prometheus/latest/configuration/configuration/#tsdb # (General Setting for all metrics in this job) [ exportAllDataPoints: ] ``` -------------------------------- ### Install Grizzly and Apply Mixin Source: https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/mixin/README.md Installs the Grizzly tool and applies the CloudWatch Mixin to your Grafana instance. Grizzly is used for managing Grafana configurations. ```bash go install github.com/grafana/grizzly/cmd/grr@latest grr apply mixin.libsonnet ``` -------------------------------- ### Configure Search Tags Source: https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/docs/configuration.md Define tags to filter resources during discovery. This example uses a 'env' key with a 'production' value. ```yaml searchTags: - key: env value: production ``` -------------------------------- ### Prometheus Query Examples for AWS Services Source: https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/README.md Examples of Prometheus queries to extract and process metrics from AWS services like Elasticsearch and ELB, often combined with AWS info metrics for tagging. ```promql # Free Storage in Megabytes + tag Type of the elasticsearch cluster (aws_es_free_storage_space_sum + on (name) group_left(tag_Type) aws_es_info) / 1024 ``` ```promql # Add kubernetes / kops tags on 4xx elb metrics (aws_elb_httpcode_backend_4_xx_sum + on (name) group_left(tag_KubernetesCluster,tag_kubernetes_io_service_name) aws_elb_info) ``` ```promql # Availability Metric for ELBs (Successful requests / Total Requests) + k8s service name # Use nilToZero on all metrics else it won't work ((aws_elb_request_count_sum - on (name) group_left() aws_elb_httpcode_backend_4_xx_sum) - on (name) group_left() aws_elb_httpcode_backend_5_xx_sum) + on (name) group_left(tag_kubernetes_io_service_name) aws_elb_info ``` ```promql # Forecast your elasticsearch disk size in 7 days and report metrics with tags type and version predict_linear(aws_es_free_storage_space_minimum[2d], 86400 * 7) + on (name) group_left(tag_type, tag_version) aws_es_info ``` ```promql # Forecast your cloudwatch costs for next 32 days based on last 10 minutes # 1.000.000 Requests free # 0.01 Dollar for 1.000 GetMetricStatistics Api Requests (https://aws.amazon.com/cloudwatch/pricing/) ((increase(yace_cloudwatch_requests_total[10m]) * 6 * 24 * 32) - 100000) / 1000 * 0.01 ``` -------------------------------- ### Configure Custom Tags Source: https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/docs/configuration.md Add custom tags to metrics. This example adds a 'CustomTag' with the value 'CustomValue'. ```yaml customTags: - key: CustomTag value: CustomValue ``` -------------------------------- ### Install YACE with Kubernetes Manifests Source: https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/docs/installation.md This YAML defines a ConfigMap for YACE configuration and a Deployment to run the exporter in Kubernetes. Remember to replace `vX.Y.Z` with the desired release version. ```yaml --- apiVersion: v1 kind: ConfigMap metadata: name: yace data: config.yml: |- --- # Start of config file --- apiVersion: apps/v1 kind: Deployment metadata: name: yace spec: replicas: 1 selector: matchLabels: name: yace template: metadata: labels: name: yace spec: containers: - name: yace image: quay.io/prometheuscommunity/yet-another-cloudwatch-exporter:vX.Y.Z # release version as tag - Do not forget the version 'v' imagePullPolicy: IfNotPresent args: - "--config.file=/tmp/config.yml" ports: - name: app containerPort: 5000 volumeMounts: - name: config-volume mountPath: /tmp volumes: - name: config-volume configMap: name: yace ``` -------------------------------- ### Enable Enhanced Metrics Source: https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/docs/configuration.md Enable enhanced metrics for specific AWS services and metrics. This example enables the 'ItemCount' enhanced metric. ```yaml enhancedMetrics: - name: ItemCount ``` -------------------------------- ### Configure Dimensions Source: https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/docs/configuration.md Specify dimensions to filter metrics. This example uses the 'AutoScalingGroupName' dimension with the value 'MyGroup'. ```yaml dimensions: - name: AutoScalingGroupName value: MyGroup ``` -------------------------------- ### YAML Configuration File Structure Source: https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/docs/configuration.md Defines the top-level structure of the YACE YAML configuration file. At least one of 'discovery', 'static', or 'customNamespace' must be defined. ```yaml apiVersion: v1alpha1 [ sts-region: ] # Note that at least one of the following blocks must be defined. # Configurations for jobs of type "auto-discovery" discovery: # Configurations for jobs of type "static" static: [ - ... ] # Configurations for jobs of type "custom namespace" customNamespace: [ - ... ] ``` -------------------------------- ### Run YACE with Docker Source: https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/docs/installation.md Use this command to pull and run the YACE Docker image locally. Ensure you map your AWS credentials and configuration file. ```shell docker run -d --rm \ -v $PWD/credentials:/home/.aws/credentials \ -v $PWD/config.yml:/tmp/config.yml \ -p 5000:5000 \ --name yace quay.io/prometheuscommunity/yet-another-cloudwatch-exporter:latest ``` -------------------------------- ### Minimum Permissions for Static and Discovery Jobs Source: https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/README.md These are the essential permissions required to run Static and Discovery Jobs within YACE. ```json "tag:GetResources", "cloudwatch:GetMetricData", "cloudwatch:GetMetricStatistics", "cloudwatch:ListMetrics" ``` -------------------------------- ### Docker Run Command with Endpoint Override Source: https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/README.md This command demonstrates how to run the Yet Another CloudWatch Exporter Docker container, overriding the default AWS endpoint URL for local testing. ```shell docker run -d --rm -v $PWD/credentials:/home/.aws/credentials -v $PWD/config.yml:/tmp/config.yml \ -e AWS_ENDPOINT_URL=http://localhost:4766 -p 5000:5000 --name yace quay.io/prometheuscommunity/yet-another-cloudwatch-exporter:latest ``` -------------------------------- ### Permissions for AWS/StorageGateway Namespace Source: https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/README.md These permissions are required to discover resources for the AWS/StorageGateway namespace. ```json "storagegateway:ListGateways", "storagegateway:ListTagsForResource" ``` -------------------------------- ### Permissions for AWS/AutoScaling Namespace Source: https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/README.md This permission is required to discover resources for the AWS/AutoScaling namespace. ```json "autoscaling:DescribeAutoScalingGroups" ``` -------------------------------- ### Permissions for AWS/DMS Namespace Source: https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/README.md These permissions are needed to discover resources for the AWS/DMS namespace. ```json "dms:DescribeReplicationInstances", "dms:DescribeReplicationTasks" ``` -------------------------------- ### Permissions for AWS/Prometheus Namespace Source: https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/README.md This permission is required to discover resources for the AWS/Prometheus namespace. ```json "aps:ListWorkspaces" ``` -------------------------------- ### YAML Configuration for Multi-Account ECS Monitoring Source: https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/README.md This YAML configuration shows how to set up Yet Another CloudWatch Exporter to monitor ECS clusters across multiple AWS accounts using role ARNs and specifying regions. ```yaml apiVersion: v1alpha1 sts-region: eu-west-1 discovery: jobs: - type: AWS/ECS regions: - eu-north-1 roles: - roleArn: "arn:aws:iam::1111111111111:role/prometheus" # newspaper - roleArn: "arn:aws:iam::2222222222222:role/prometheus" # radio - roleArn: "arn:aws:iam::3333333333333:role/prometheus" # television metrics: - name: MemoryReservation statistics: - Average - Minimum - Maximum period: 600 length: 600 ``` -------------------------------- ### Permissions for AWS/DDoSProtection Namespace Source: https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/README.md This permission is required to discover protected resources for the AWS/DDoSProtection namespace. ```json "shield:ListProtections" ``` -------------------------------- ### Auto-Discovery Job Configuration Source: https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/docs/configuration.md Configures jobs for automatically discovering AWS resources to monitor. Only tagged resources are discovered. Supports specifying exported tags, regions, services, roles, search tags, custom tags, and dimension requirements. ```yaml # List of tags per service to export to all metrics [exportedTagsOnMetrics: ] # List of "auto-discovery" jobs jobs: [ - ... ] ``` ```yaml # List of AWS regions regions: [ - ... ] # Cloudwatch service alias ("alb", "ec2", etc) or namespace name ("AWS/EC2", "AWS/S3", etc) type: # List of IAM roles to assume (optional) roles: [ - ... ] # List of Key/Value pairs to use for tag filtering (all must match). # The key is the AWS Tag key and is case-sensitive # The value will be treated as a regex searchTags: [ - ... ] # Custom tags to be added as a list of Key/Value pairs customTags: [ - ... ] # List of metric dimensions to query. Before querying metric values, the total list of metrics will be filtered to only those that contain exactly this list of dimensions. An empty or undefined list results in all dimension combinations being included. dimensionNameRequirements: [ - ... ] # Specifies how the current time is rounded before calculating start/end times for CloudWatch GetMetricData requests. # This rounding is optimize performance of the CloudWatch request. ``` -------------------------------- ### Permissions for AWS/EC2Spot Namespace Source: https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/README.md This permission is required to discover resources for the AWS/EC2Spot namespace. ```json "ec2:DescribeSpotFleetRequests" ``` -------------------------------- ### IAM Policy for YACE Source: https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/README.md This IAM policy grants all necessary permissions for YACE to function correctly. Adjust permissions based on your specific needs and the CloudWatch namespaces you are scraping. ```json { "Version": "2012-10-17", "Statement": [ { "Action": [ "tag:GetResources", "cloudwatch:GetMetricData", "cloudwatch:GetMetricStatistics", "cloudwatch:ListMetrics", "apigateway:GET", "aps:ListWorkspaces", "autoscaling:DescribeAutoScalingGroups", "dms:DescribeReplicationInstances", "dms:DescribeReplicationTasks", "ec2:DescribeTransitGatewayAttachments", "ec2:DescribeSpotFleetRequests", "shield:ListProtections", "storagegateway:ListGateways", "storagegateway:ListTagsForResource", "iam:ListAccountAliases" ], "Effect": "Allow", "Resource": "*" } ] } ``` -------------------------------- ### Permissions for AWS/TransitGateway Namespace Source: https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/README.md This permission is required to discover resources for the AWS/TransitGateway namespace. ```json "ec2:DescribeTransitGatewayAttachments" ``` -------------------------------- ### Permissions for AWS/ApiGateway Namespace Source: https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/README.md This permission is necessary for discovering resources within the AWS/ApiGateway namespace. ```json "apigateway:GET" ``` -------------------------------- ### YAML Configuration with External ID for IAM Role Assumption Source: https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/README.md This YAML snippet illustrates how to specify an External ID when assuming an IAM role, which is necessary for enhanced security in certain AWS cross-account access scenarios. ```yaml roles: - roleArn: "arn:aws:iam::1111111111111:role/prometheus" externalId: "shared-external-identifier" ``` -------------------------------- ### Permissions for AWS Account Alias Metric Source: https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/README.md This permission is required to retrieve the AWS account alias, which is exported as a label in the `aws_account_info` metric. ```json "iam:ListAccountAliases" ``` -------------------------------- ### Configure IAM Role ARN Source: https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/docs/configuration.md Specify the IAM role ARN to assume for accessing AWS services. An optional external ID can also be provided for enhanced security. ```yaml roles: - roleArn: "arn:aws:iam::123456789012:role/Prometheus" externalId: "shared-external-identifier" # optional ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.