Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: add statsd collector to prometheus deployment #53

Merged
merged 5 commits into from
Oct 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pulumi/aws/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions pulumi/aws/config/Pulumi.stackname.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -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

############################################################################

Expand Down
102 changes: 102 additions & 0 deletions pulumi/aws/prometheus/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))