Add stackdriver-exporter (#4167)

* Add stackdriver-exporter

Stackdriver-exporter gathers metrics from Google Cloud projects and
presents them for Prometheus to gather.

* Update URL

* Switch to lowerCamelCase across the chart

* Use Helm 2.8 _helpers.tpl as a foundation.

* Fix chart label
This commit is contained in:
Ashley Penney
2018-03-27 13:07:02 -07:00
committed by k8s-ci-robot
parent 54bf0b00fb
commit 6020983d5c
7 changed files with 300 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
apiVersion: v1
description: Stackdriver exporter for Prometheus
name: stackdriver-exporter
version: 0.0.1
appVersion: 0.5.1
sources:
- https://github.com/frodenas/stackdriver_exporter/releases
keywords:
- metrics
- stackdriver
- monitoring
maintainers:
- name: apenney
email: apenney@gmail.com
+103
View File
@@ -0,0 +1,103 @@
# Stackdriver Exporter
Prometheus exporter for Stackdriver, allowing for Google Cloud metrics. You
must have appropriate IAM permissions for this to exporter to work. If you
are passing in an IAM key then you must have:
* monitoring.metricDescriptors.list
* monitoring.timeSeries.list
These are contained within `roles/monitoring.viewer`. If you're using legacy
access scopes, then you must have
`https://www.googleapis.com/auth/monitoring.read`.
Learn more: https://github.com/frodenas/stackdriver_exporter
## TL;DR;
```bash
$ helm install stable/stackdriver-exporter --set stackdriver.projectId=google-project-name
```
## Introduction
This chart creates a Stackdriver-Exporter deployment on a
[Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh)
package manager.
## Prerequisites
- Kubernetes 1.8+ with Beta APIs enabled
## Installing the Chart
To install the chart with the release name `my-release`:
```bash
$ helm install --name my-release stable/stackdriver-exporter --set stackdriver.projectId=google-project-name
```
The command deploys Stackdriver-Exporter on the Kubernetes cluster using the
default configuration. The [configuration](#configuration) section lists the
parameters that can be configured during installation.
## Uninstalling the Chart
To uninstall/delete the `my-release` deployment:
```bash
$ helm delete --purge my-release
```
The command removes all the Kubernetes components associated with the chart and
deletes the release.
## Configuration
The following table lists the configurable parameters of the
Stackdriver-Exporter chart and their default values.
Parameter | Description | Default
----------------------------------- | ------------------------------------ | --------------------------------
`replicaCount` | desired number of pods | `1`
`restartPolicy` | container restart policy | `Always`
`image.repository` | container image repository | `justwatch/stackdriver_exporter`
`image.tag` | container image tag | `1.0.2`
`image.pullPolicy` | container image pull policy | `IfNotPresent`
`resources` | resource requests & limits | `{}`
`service.type` | type of service to create | `ClusterIP`
`service.httpPort` | port for the http service | `9255`
`stackdriver.projectId` | GCP Project ID | ``
`stackdriver.metrics.typePrefixes` | Comma separated Metric Type prefixes | ``
`stackdriver.metrics.interval` | Metrics interval to request from GCP | `5m`
`stackdriver.metrics.offset` | Offset (into the past) to request | `0s`
`web.listenAddress` | Port to listen on | `9255`
`web.path` | Path under which to expose metrics | `/metrics`
Specify each parameter using the `--set key=value[,key=value]` argument to
`helm install`. For example,
```bash
$ helm install --name my-release \
--set key_1=value_1,key_2=value_2 \
stable/stackdriver-exporter
```
Alternatively, a YAML file that specifies the values for the parameters can be
provided while installing the chart. For example,
```bash
# example for staging
$ helm install --name my-release -f values.yaml stable/stackdriver-exporter
```
> **Tip**: You can use the default [values.yaml](values.yaml), as long as you provide a value for stackdriver.projectId
## Google Storage Metrics
In order to get metrics for GCS you need to ensure the metrics interval is >
24h. You can read more information about this in [this bug
report](https://github.com/frodenas/stackdriver_exporter/issues/14).
The easiest way to do this is to create two separate exporters with different
prefixes and intervals, to ensure you gather all appropriate metrics.
@@ -0,0 +1,27 @@
{{- if eq (printf "%s" .Values.stackdriver.projectId) "FALSE" }}
######################################################################################
#### ERROR: You did not set stackdriver.projectId in your `helm install' call. ####
######################################################################################
This deployment will be incomplete until you set an appropriate Google Cloud
Project ID so we know where to gather metrics from. You can do this by:
helm upgrade {{ .Release.Name }} \
--set stackdriver.projectId=project-id stable/stackdriver-exporter
{{- end }}
1. Get the application URL by running these commands:
{{- if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "stackdriver-exporter.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT{{ .Values.web.path }}
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get svc -w {{ template "stackdriver-exporter.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "stackdriver-exporter.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo http://$SERVICE_IP:{{ .Values.service.httpPort }}{{ .Values.web.path }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "stackdriver-exporter.fullname" . }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:{{ .Values.service.httpPort }}{{ .Values.web.path }} to use your application"
kubectl port-forward $POD_NAME {{ .Values.service.httpPort }}:{{ .Values.service.httpPort }} --namespace {{ .Release.Namespace }}
{{- end }}
@@ -0,0 +1,32 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "stackdriver-exporter.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "stackdriver-exporter.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "stackdriver-exporter.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
@@ -0,0 +1,62 @@
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: {{ template "stackdriver-exporter.fullname" . }}
labels:
chart: {{ template "stackdriver-exporter.chart" . }}
app: {{ template "stackdriver-exporter.name" . }}
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ template "stackdriver-exporter.name" . }}
release: "{{ .Release.Name }}"
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
type: RollingUpdate
template:
metadata:
labels:
app: {{ template "stackdriver-exporter.name" . }}
release: "{{ .Release.Name }}"
spec:
restartPolicy: {{ .Values.restartPolicy }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command: ["stackdriver_exporter"]
env:
- name: STACKDRIVER_EXPORTER_GOOGLE_PROJECT_ID
value: {{ .Values.stackdriver.projectId | quote }}
- name: STACKDRIVER_EXPORTER_MONITORING_METRICS_TYPE_PREFIXES
value: {{ .Values.stackdriver.metrics.typePrefixes | quote }}
- name: STACKDRIVER_EXPORTER_MONITORING_METRICS_INTERVAL
value: {{ .Values.stackdriver.metrics.interval | quote }}
- name: STACKDRIVER_EXPORTER_MONITORING_METRICS_OFFSET
value: {{ .Values.stackdriver.metrics.offset | quote }}
- name: STACKDRIVER_EXPORTER_WEB_LISTEN_ADDRESS
value: {{ .Values.web.listenAddress | quote }}
- name: STACKDRIVER_EXPORTER_WEB_TELEMETRY_PATH
value: {{ .Values.web.path | quote }}
resources:
{{ toYaml .Values.resources | indent 12 }}
ports:
- containerPort: {{ .Values.service.httpPort }}
name: http
livenessProbe:
httpGet:
path: /health
port: http
initialDelaySeconds: 30
timeoutSeconds: 10
livenessProbe:
httpGet:
path: /health
port: http
initialDelaySeconds: 10
timeoutSeconds: 10
@@ -0,0 +1,22 @@
kind: Service
apiVersion: v1
metadata:
name: {{ template "stackdriver-exporter.fullname" . }}
labels:
chart: {{ template "stackdriver-exporter.chart" . }}
app: {{ template "stackdriver-exporter.name" . }}
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
{{- if .Values.service.annotations }}
annotations:
{{ toYaml .Values.service.annotations | indent 4 }}
{{- end }}
spec:
type: {{ .Values.service.type }}
ports:
- name: http
port: {{ .Values.service.httpPort }}
protocol: TCP
selector:
app: {{ template "stackdriver-exporter.name" . }}
release: "{{ .Release.Name }}"
+40
View File
@@ -0,0 +1,40 @@
# Number of exporters to run
replicaCount: 1
# Restart policy for container
restartPolicy: Always
image:
repository: frodenas/stackdriver-exporter
tag: v0.5.1
pullPolicy: IfNotPresent
resources: {}
# requests:
# cpu: 100m
# memory: 128Mi
# limits:
# cpu: 100m
# memory: 128Mi
service:
type: ClusterIP
httpPort: 9255
annotations: {}
stackdriver:
# The Google Project ID to gather metrics for
projectId: "FALSE"
metrics:
# The prefixes to gather metrics for, we default to just CPU metrics.
typePrefixes: 'compute.googleapis.com/instance/cpu'
# The frequency to request
interval: '5m'
# How far into the past to offset
offset: '0s'
web:
# Port to listen on
listenAddress: ':9255'
# Path under which to expose metrics.
path: /metrics