diff --git a/pulumi/aws/README.md b/pulumi/aws/README.md index 61163aba..d02e1594 100644 --- a/pulumi/aws/README.md +++ b/pulumi/aws/README.md @@ -31,7 +31,7 @@ vpc - defines and installs the VPC and subnets to use with EKS └─logstore - deploys a logstore (elasticsearch) to the EKS cluster └─logagent - deploys a logging agent (filebeat) to the EKS cluster └─certmgr - deploys the open source cert-manager.io helm chart to the EKS cluster - └─prometheus - deploys prometheus server and node exporter for metrics + └─prometheus - deploys prometheus server, node exporter, and statsd collector for metrics └─grafana - deploys the grafana visualization platform └─sirius - deploys the Bank of Sirus application to the EKS cluster diff --git a/pulumi/aws/config/Pulumi.stackname.yaml.example b/pulumi/aws/config/Pulumi.stackname.yaml.example index 3250491f..e9ada9ea 100644 --- a/pulumi/aws/config/Pulumi.stackname.yaml.example +++ b/pulumi/aws/config/Pulumi.stackname.yaml.example @@ -204,6 +204,10 @@ config: prometheus:helm_repo_name: prometheus-community # Name of the repo to pull the prometheus chart from prometheus:helm_repo_url: https://https://prometheus-community.github.io/helm-charts + # Name of the statsd chart (uses the same repo as the prom chart) + prometheus:statsd_chart_name: prometheus-statsd-exporter + # Version of the statsd chart (uses the same repo as the prom chart) + prometheus.statsd_chart_version: 0.3.1 ############################################################################ diff --git a/pulumi/aws/prometheus/__main__.py b/pulumi/aws/prometheus/__main__.py index 7cdd88d4..e2ebd43b 100644 --- a/pulumi/aws/prometheus/__main__.py +++ b/pulumi/aws/prometheus/__main__.py @@ -63,3 +63,105 @@ def project_name_from_project_dir(dirname: str): prometheus_chart = helm.Chart(release_name='prometheus', config=chart_ops, opts=pulumi.ResourceOptions(provider=k8s_provider)) + +# +# Deploy the statsd collector +# + +statsd_chart_values = { + "replicaCount": 1, + "image": { + "repository": "prom/statsd-exporter", + "pullPolicy": "IfNotPresent", + "tag": "v0.20.0" + }, + "imagePullSecrets": [], + "nameOverride": "", + "fullnameOverride": "", + "statsd": { + "udpPort": 9125, + "tcpPort": 9125, + "cacheSize": 1000, + "eventQueueSize": 10000, + "eventFlushThreshold": 1000, + "eventFlushInterval": "200ms" + }, + "serviceMonitor": { + "enabled": False, + "interval": "30s", + "scrapeTimeout": "10s", + "namespace": "monitoring", + "honorLabels": False, + "additionalLabels": {} + }, + "serviceAccount": { + "create": True, + "annotations": {}, + "name": "" + }, + "podAnnotations": { + "prometheus.io/scrape": "true", + "prometheus.io/port": "9102" + }, + "podSecurityContext": {}, + "securityContext": {}, + "service": { + "type": "ClusterIP", + "port": 9102, + "path": "/metrics", + "annotations": {} + }, + "ingress": { + "enabled": False, + "annotations": {}, + "hosts": [ + { + "host": "chart-example.local", + "paths": [] + } + ], + "tls": [] + }, + "resources": {}, + "autoscaling": { + "enabled": False, + "minReplicas": 1, + "maxReplicas": 100, + "targetCPUUtilizationPercentage": 80 + }, + "nodeSelector": {}, + "tolerations": [], + "affinity": {}, + "annotations": { + "prometheus.io/scrape": "true", + "prometheus.io/port": "9102" + } +} + +config = pulumi.Config('prometheus') +statsd_chart_name = config.get('statsd_chart_name') +if not statsd_chart_name: + statsd_chart_name = 'prometheus-statsd-exporter' +statsd_chart_version = config.get('statsd_chart_version') +if not statsd_chart_version: + statsd_chart_version = '0.3.1' +helm_repo_name = config.get('prometheus_helm_repo_name') +if not helm_repo_name: + helm_repo_name = 'prometheus-community' +helm_repo_url = config.get('prometheus_helm_repo_url') +if not helm_repo_url: + helm_repo_url = 'https://prometheus-community.github.io/helm-charts' + +statsd_chart_ops = helm.ChartOpts( + chart=statsd_chart_name, + namespace=ns.metadata.name, + repo=helm_repo_name, + fetch_opts=FetchOpts(repo=helm_repo_url), + version=statsd_chart_version, + values=statsd_chart_values, + transformations=[remove_status_field] +) + +statsd_chart = helm.Chart(release_name='statsd', + config=statsd_chart_ops, + opts=pulumi.ResourceOptions(provider=k8s_provider)) \ No newline at end of file