How to get the Stackdriver charts into a csv file?

8/29/2019

I am using Stackdriver to monitor the clusters deployed in Kubernetes in GCP. In Stackdriver monitoring overview tab, I am able to see different charts showing resource utilization vs time. I want to convert this charts to a csv file which contains the resource utilization for every second. Has anyone done this before or have an idea of how to do it?

-- anushiya-thevapalan
google-cloud-stackdriver
kubernetes
metrics
monitoring

1 Answer

8/29/2019

There isn't an "easy" way built into Stackdriver to export metrics to a .csv file.

Probably the "easiest" way is by using this project on github that is a Google App Engine service to export to a .csv file. It is in Alpha, and you need to install it. https://github.com/CloudMile/stackdriver-monitoring-exporter

The recommended way to export is explained here. https://cloud.google.com/solutions/stackdriver-monitoring-metric-export and this method is geared toward archiving large amounts of metric data for later comparison, not really for smaller amounts to a spreadsheet.

The recommended way requires using the Monitoring API (https://cloud.google.com/monitoring/custom-metrics/reading-metrics) which returns JSON, which you'd have to convert to a .csv file. You could probably get curl or postman to make the calls.

Here's an other example project on github. This sends the data to bigquery for storage though. https://github.com/GoogleCloudPlatform/stackdriver-metrics-export

-- AlphaPapa
Source: StackOverflow