Skip to content

Commit

Permalink
Provide support for Runtime configuration in Helm Chart (#663)
Browse files Browse the repository at this point in the history
* WIP

* Merge config maps

* Trailing spaces

* Update README with recent sample

* Finalize runtime YAML

* Update chart info

* Update deployment docs

* Streamline log configuration
  • Loading branch information
tomkerkhove authored Aug 17, 2019
1 parent 6d67d5a commit 9ac8408
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 48 deletions.
20 changes: 14 additions & 6 deletions charts/promitor-agent-scraper/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,15 @@ The following table lists the configurable parameters of the Promitor chart and
| `image.pullPolicy` | Policy to pull image | `Always` |
| `azureAuthentication.appId` | Id of the Azure AD entity to authenticate with | |
| `azureAuthentication.appKey` | Secret of the Azure AD entity to authenticate with | |
| `scrapeConfig.path` | Path where the scraping endpoint for Prometheus is being exposed | `/metrics` |
| `scrapeConfig.timestamp` | Indication wheter or not to include timestamp | `true` |
| `telemetry.appInsightsKey` | Application Insights telemetry key | |
| `logging.minimalLogLevel` | Minimum level of logging | `Warning` |
| `runtime.prometheus.scrapeEndpointPath` | Path where the scraping endpoint for Prometheus is being exposed | `/metrics` |
| `runtime.prometheus.enableMetricTimestamps` | Indication wheter or not to include timestamp | `true` |
| `runtime.prometheus.metricUnavailableValue` | Value to report in Prometheus when no metric was found wheter or not to include timestamp | `NaN` |
| `runtime.telemetry.applicationInsights.enabled` | Indication wheter or not to send telemetry to Azure Application Insights | `false` |
| `runtime.telemetry.applicationInsights.logLevel` | Minimum level of logging for Azure Application Insights | |
| `runtime.telemetry.applicationInsights.key` | Application Insights instrumentation key | |
| `runtime.telemetry.containerLogs.enabled` | Indication wheter or not to send telemetry to container logs | `true` |
| `runtime.telemetry.containerLogs.logLevel` | Minimum level of logging for container logs | |
| `runtime.telemetry.defaultLogLevel` | Minimum level of logging for all telemetry sinks, unless specified otherwise | `Error` |
| `azureMetadata.tenantId` | Id of Azure tenant | |
| `azureMetadata.subscriptionId` | Id of Azure subscription | |
| `azureMetadata.resourceGroupName` | Name of resource group | `promitor` |
Expand All @@ -66,7 +71,6 @@ The following table lists the configurable parameters of the Promitor chart and
| `secrets.createSecret` | Indication if you want to bring your own secret level of logging | `true` |
| `secrets.appIdSecret` | Name of the secret for Azure AD identity id | `azure-app-id` |
| `secrets.appKeySecret` | Name of the secret for Azure AD identity secret | `azure-app-key` |
| `secrets.appInsightsSecret` | Name of the secret for Application Insights instrumentation key | `azure-appinsights-key` |
| `service.exposeExternally` | Indication wheter or not to expose service externally | `false` |
| `service.port` | Port on service for other pods to talk to | `8888` |
| `service.targetPort` | Port on container to serve traffic | `88` |
Expand All @@ -77,7 +81,11 @@ Specify each parameter using the `--set key=value[,key=value]` argument to `helm

```console
$ helm install promitor/promitor-agent-scraper --name promitor-agent-scraper \
--set logging.minimalLogLevel=Trace
--set azureAuthentication.appId='<azure-ad-app-id>' \
--set azureAuthentication.appKey='<azure-ad-app-key>' \
--set azureMetadata.tenantId='<azure-tenant-id>' \
--set azureMetadata.subscriptionId='<azure-subscription-id>' \
--values C:\Promitor\metric-declaration.yaml
```

Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example,
Expand Down
4 changes: 2 additions & 2 deletions charts/promitor-agent-scraper/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ include "promitor-agent-scraper.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
kubectl port-forward $POD_NAME 8080:{{ .Values.service.targetPort }}

2. Check the scraping output at http://127.0.0.1:8080{{ .Values.scrapeConfig.path }}
2. Check the scraping output at http://127.0.0.1:8080{{ .Values.runtime.prometheus.scrapeEndpointPath }}

3. To set up Prometheus in your cluster & pull in metrics from Promitor's scraping output, run:

cat > promitor-scrape-config.yaml <<EOF
extraScrapeConfigs: |
- job_name: {{ template "promitor-agent-scraper.fullname" . }}
metrics_path: {{ .Values.scrapeConfig.path }}
metrics_path: {{ .Values.runtime.prometheus.scrapeEndpointPath }}
static_configs:
- targets:
- {{ template "promitor-agent-scraper.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local:{{ .Values.service.port }}
Expand Down
27 changes: 26 additions & 1 deletion charts/promitor-agent-scraper/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,31 @@ metadata:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
data:
runtime.yaml: |-
server:
httpPort: {{ .Values.service.targetPort | quote }}
prometheus:
metricUnavailableValue: {{ .Values.runtime.prometheus.metricUnavailableValue | quote }}
enableMetricTimestamps: {{ .Values.runtime.prometheus.enableMetricTimestamps | quote }}
scrapeEndpoint:
baseUriPath: {{ .Values.runtime.prometheus.scrapeEndpointPath | quote }}
metricsConfiguration:
absolutePath: /config/metrics-declaration.yaml
telemetry:
applicationInsights:
{{- if .Values.runtime.telemetry.applicationInsights.key }}
instrumentationKey: {{ .Values.runtime.telemetry.applicationInsights.key | quote }}
{{- end }}
isEnabled: {{ .Values.runtime.telemetry.applicationInsights.enabled | quote }}
{{- if .Values.runtime.telemetry.applicationInsights.logLevel }}
verbosity: {{ .Values.runtime.telemetry.applicationInsights.logLevel | quote }}
{{- end }}
containerLogs:
isEnabled: {{ .Values.runtime.telemetry.containerLogs.enabled | quote }}
{{- if .Values.runtime.telemetry.containerLogs.logLevel }}
verbosity: {{ .Values.runtime.telemetry.containerLogs.logLevel | quote }}
{{- end }}
defaultVerbosity: {{ .Values.runtime.telemetry.defaultLogLevel | quote }}
metrics-declaration.yaml: |-
version: v1
azureMetadata:
Expand All @@ -21,4 +46,4 @@ data:
scraping:
schedule: {{ .Values.metricDefaults.scraping.schedule | quote }}
metrics:
{{ tpl $metrics . | indent 4 }}
{{ tpl $metrics . | indent 4 }}
17 changes: 0 additions & 17 deletions charts/promitor-agent-scraper/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,6 @@ spec:
secretKeyRef:
name: {{ template "promitor-agent-scraper.secretname" . }}
key: {{ .Values.secrets.appKeySecret }}
- name: PROMITOR_HTTP_PORT
value: {{ .Values.service.targetPort | quote }}
- name: PROMITOR_SCRAPE_BASEPATH
value: {{ .Values.scrapeConfig.path | quote }}
- name: PROMITOR_FEATURE_METRICSTIMESTAMP
value: {{ .Values.scrapeConfig.timestamp | quote }}
{{- if .Values.telemetry.appInsightsKey }}
- name: PROMITOR_TELEMETRY_INSTRUMENTATIONKEY
valueFrom:
secretKeyRef:
name: {{ template "promitor-agent-scraper.secretname" . }}
key: {{ .Values.secrets.appInsightsSecret }}
{{- end }}
{{- if .Values.logging.minimalLogLevel }}
- name: PROMITOR_LOGGING_MINIMUMLEVEL
value: {{ .Values.logging.minimalLogLevel }}
{{- end }}
resources:
{{ toYaml .Values.resources | indent 12 }}
volumeMounts:
Expand Down
3 changes: 0 additions & 3 deletions charts/promitor-agent-scraper/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,4 @@ type: Opaque
data:
{{ .Values.secrets.appIdSecret }}: {{ .Values.azureAuthentication.appId | b64enc | quote }}
{{ .Values.secrets.appKeySecret }}: {{ .Values.azureAuthentication.appKey | b64enc | quote }}
{{- if .Values.telemetry.appInsightsKey }}
{{ .Values.secrets.appInsightsSecret }}: {{ .Values.telemetry.appInsightsKey | b64enc | quote }}
{{- end }}
{{- end }}
23 changes: 14 additions & 9 deletions charts/promitor-agent-scraper/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,20 @@ azureAuthentication:
appId: ""
appKey: ""

scrapeConfig:
path: /metrics
timestamp: True

telemetry:
appInsightsKey: ""

logging:
minimalLogLevel: "Warning"
runtime:
prometheus:
scrapeEndpointPath: /metrics
enableMetricTimestamps: True
metricUnavailableValue: NaN
telemetry:
defaultLogLevel: "Error"
applicationInsights:
enabled: False
key: ""
logLevel: ""
containerLogs:
enabled: True
logLevel: ""

## Metric Declaration YAML
azureMetadata:
Expand Down
34 changes: 24 additions & 10 deletions docs/deployment/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,29 @@ azureAuthentication:
# PROMITOR_AUTH_APPKEY (Required)
appKey: "<azure-ad-app-key>"

scrapeConfig:
# PROMITOR_SCRAPE_BASEPATH (Optional, default is shown)
path: /metrics
# PROMITOR_FEATURE_METRICSTIMESTAMP (Optional, default is shown)
timestamp: True

telemetry:
# PROMITOR_TELEMETRY_INSTRUMENTATIONKEY (Optional)
appInsightsKey: "<azure-app-insights-key>"
azureMetadata:
tenantId: "<azure-tenant-id>"
subscriptionId: "<azure-subscription-id>"

runtime:
prometheus:
scrapeEndpointPath: /metrics
enableMetricTimestamps: True
telemetry:
applicationInsights:
enabled: True
key: "<azure-app-insights-key>"

metrics:
- name: promitor_demo_servicebusqueue_queue_size
description: "Amount of active messages of the 'orders' queue (determined with ServiceBusQueue provider)"
resourceType: ServiceBusQueue
namespace: promitor-messaging
queueName: orders
azureMetricConfiguration:
metricName: ActiveMessages
aggregation:
type: Average
```
Check the [full values file](https://github.com/tomkerkhove/promitor/blob/master/charts/promitor-agent-scraper/values.yaml) to see all configurable values.
Expand All @@ -64,7 +78,7 @@ If you have a `metric-declaration.yaml` file, you can create a basic deployment
❯ helm install --name promitor-agent-scraper promitor/promitor-agent-scraper \
--set azureAuthentication.appId='<azure-ad-app-id>' \
--set azureAuthentication.appKey='<azure-ad-app-key>' \
--values /path/to/metric-declaration.yaml
--values /path/to/helm-configuration.yaml
```
# Image Tagging Strategy
Expand Down

0 comments on commit 9ac8408

Please sign in to comment.