prometheus-exporter-aws-rds-engine-version

command module
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2023 License: MIT Imports: 11 Imported by: 0

README

prometheus-exporter-aws-rds-engine-version

This tool exports metrics related to RDS clusters and their instances for Prometheus. It verifies the engine version of each cluster and instance and creates a metric indicating if the current version is deprecated or available. The metric is updated at a configurable interval.

Prerequisites

IAM Roles & Policies

This exporter will use IRSA to assume a role on which we'll attach the following policy.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "",
            "Effect": "Allow",
            "Action": [
                "rds:DescribeDBInstances",
                "rds:DescribeDBClusters",
                "rds:DescribeDBEngineVersions"
            ],
            "Resource": "*"
        }
    ]
}

Installation

git clone https://github.com/alexandremahdhaoui/prometheus-exporter-aws-rds-engine-version
cd prometheus-exporter-aws-rds-engine-version

Build the application.

go build

Configuration

The exporter requires the following environment variables:

Name Description
EXPORTER_AWS_API_INTERVAL_SECONDS the interval in seconds to update the metrics (recommended: 300).
EXPORTER_SERVER_PORT the port number that the server listens on (recommended: 2112).

Usage

Start the exporter by running the following command:

./prometheus-exporter-aws-rds-engine-version

Access the metrics on the server's endpoint:

curl http://localhost:2112/metrics
Metrics
Name Description Tags
aws_custom_rds_version_available Number of instances running an available rds version "cluster_identifier", "engine", "engine_version"
aws_custom_rds_version_deprecated Number of instances running a deprecated rds version "cluster_identifier", "engine", "engine_version"

License

MIT License

Contributing

Contributions are welcome. Feel free to open a pull request or an issue if you encounter any problems.

Disclaimer

This project is a fork of chapsy/aws-rds-engine-version-prometheus-exporter.

Documentation

Overview

Package main provides a program that periodically collects metrics about Amazon RDS clusters and instances and exports them in Prometheus format. It uses the AWS SDK for Go and the Prometheus Go client library to perform these operations.

The program reads two environment variables: EXPORTER_AWS_API & INTERVAL_SECONDS, which specifies the time interval in seconds for fetching the data, and EXPORTER_SERVER_PORT, which specifies the port number for serving the Prometheus metrics.

The program defines two main types: Config, which holds the AWS RDS API client, and Metrics, which holds the Prometheus metrics. The program also defines a struct RDSInfo to represent information about an Amazon RDS cluster.

The main() function initializes the program by setting up the configuration, metrics, and HTTP server, and then starts a goroutine that periodically fetches RDS cluster and instance data and exports the metrics. The goroutine uses the snapshot() function to fetch the data and export the metrics.

The snapshot() function fetches RDS cluster and instance data, merges them into a single slice of RDSInfos, and then exports the metrics for each RDSInfo. If any error occurs during the metric exporting process, the function will skip the problematic RDSInfo and continue exporting other RDSInfos.

The export() function collects RDS info and validates its engine version against a map of allowed engine versions. If the version is deprecated, it will set the deprecatedGauge Prometheus metric to 1 and the availableGauge metric to 0, and vice versa if the version is available.

The program also defines two helper functions: getEnvInteger() to read integer environment variables, and initHttpServer() to initialize the HTTP server.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL