A Prometheus exporter for Google Stackdriver Monitoring metrics. It acts as a proxy that requests Stackdriver API for the metric's time-series everytime prometheus scrapes it.
Download the already existing binaries for your platform:
$ ./stackdriver_exporter <flags>
Using the standard go install
(you must have Go already installed in your local machine):
$ go install github.com/frodenas/stackdriver_exporter
$ stackdriver_exporter <flags>
To run the stackdriver exporter as a Docker container, run:
$ docker run -p 9255:9255 frodenas/stackdriver-exporter <flags>
The exporter can be deployed to an already existing Cloud Foundry environment:
$ git clone https://github.com/frodenas/stackdriver_exporter.git
$ cd stackdriver_exporter
Modify the included application manifest file to include the desired properties. Then you can push the exporter to your Cloud Foundry environment:
$ cf push
This exporter can be deployed using the Prometheus BOSH Release.
The Google Stackdriver Exporter uses the Google Golang Client Library, which offers a variety of ways to provide credentials. Please refer to the Google Application Default Credentials documentation to see how the credentials can be provided.
If you are using IAM roles, the monitoring.metricDescriptors.list
and monitoring.timeSeries.list
IAM permissions are required. The roles/monitoring.viewer
IAM role contains those permissions. See the Access Control Guide for more information.
If you are still using the legacy Access scopes, the https://www.googleapis.com/auth/monitoring.read
scope is required.
Flag / Environment Variable | Required | Default | Description |
---|---|---|---|
google.project-id STACKDRIVER_EXPORTER_GOOGLE_PROJECT_ID |
Yes | Google Project ID | |
monitoring.metrics-type-prefixes STACKDRIVER_EXPORTER_MONITORING_METRICS_TYPE_PREFIXES |
Yes | Comma separated Google Stackdriver Monitoring Metric Type prefixes (see example and available metrics) | |
monitoring.metrics-interval STACKDRIVER_EXPORTER_MONITORING_METRICS_INTERVAL |
No | 5m |
Metric's timestamp interval to request from the Google Stackdriver Monitoring Metrics API. Only the most recent data point is used |
monitoring.metrics-offset STACKDRIVER_EXPORTER_MONITORING_METRICS_OFFSET |
No | 0s |
Offset (into the past) for the metric's timestamp interval to request from the Google Stackdriver Monitoring Metrics API, to handle latency in published metrics |
web.listen-address STACKDRIVER_EXPORTER_WEB_LISTEN_ADDRESS |
No | :9255 |
Address to listen on for web interface and telemetry |
web.telemetry-path STACKDRIVER_EXPORTER_WEB_TELEMETRY_PATH |
No | /metrics |
Path under which to expose Prometheus metrics |
The exporter returns the following metrics:
Metric | Description | Labels |
---|---|---|
stackdriver_monitoring_api_calls_total |
Total number of Google Stackdriver Monitoring API calls made | project_id |
stackdriver_monitoring_scrapes_total |
Total number of Google Stackdriver Monitoring metrics scrapes | project_id |
stackdriver_monitoring_scrape_errors_total |
Total number of Google Stackdriver Monitoring metrics scrape errors | project_id |
stackdriver_monitoring_last_scrape_error |
Whether the last metrics scrape from Google Stackdriver Monitoring resulted in an error (1 for error, 0 for success) |
project_id |
stackdriver_monitoring_last_scrape_timestamp |
Number of seconds since 1970 since last metrics scrape from Google Stackdriver Monitoring | project_id |
stackdriver_monitoring_last_scrape_duration_seconds |
Duration of the last metrics scrape from Google Stackdriver Monitoring | project_id |
Metrics gathered from Google Stackdriver Monitoring are converted to Prometheus metrics:
- Metric's names are normalized according to the Prometheus specification using the following pattern:
namespace
is a constant prefix (stackdriver
)subsystem
is the normalized monitored resource type (iegce_instance
)name
is the normalized metric type (iecompute_googleapis_com_instance_cpu_usage_time
)
- Labels attached to each metric are an aggregation of:
- the
unit
in which the metric value is reported - the metric type labels (see Metrics List)
- the monitored resource labels (see Monitored Resource Types)
- the
- For each timeseries, only the most recent data point is exported.
- Stackdriver
GAUGE
andDELTA
metric kinds are reported as PrometheusGauge
metrics; StackdriverCUMULATIVE
metric kinds are reported as PrometheusCounter
metrics. - Only
BOOL
,INT64
,DOUBLE
andDISTRIBUTION
metric types are supported, other types (STRING
andMONEY
) are discarded. DISTRIBUTION
metric type is reported as a PrometheusHistogram
, except the_sum
time series is not supported.
If we want to get all CPU
(compute.googleapis.com/instance/cpu
) and Disk
(compute.googleapis.com/instance/disk
) metrics for all Google Compute Engine instances, we can run the exporter with the following options:
stackdriver_exporter \
--google.project-id my-test-project \
--monitoring.metrics-type-prefixes "compute.googleapis.com/instance/cpu,compute.googleapis.com/instance/disk"
Refer to the contributing guidelines.
Apache License 2.0, see LICENSE.