Skip to content

Commit

Permalink
Monitoring setup
Browse files Browse the repository at this point in the history
  • Loading branch information
gitkvark committed Dec 21, 2023
1 parent 68752ac commit 86b7f64
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 0 deletions.
24 changes: 24 additions & 0 deletions helm/monitoring/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: monitoring-chart
description: A Helm chart for setting up things related to monitoring.

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.6

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
30 changes: 30 additions & 0 deletions helm/monitoring/templates/postgrespodmonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: postgresql
spec:
selector:
matchLabels:
application: spilo # (1)
namespaceSelector:
any: true # (2)
podMetricsEndpoints:
- port: exporter # (3)
interval: 15s
scrapeTimeout: 10s
- targetPort: 8008 # (4)
interval: 15s
scrapeTimeout: 10s
podTargetLabels: # (5)
- spilo-role
- cluster-name
- team

# (1) The selector for this PodMonitor targets all spilo applications. spilo is the image that the postgres-operator uses and contains PostgreSQL, splio and everything needed to cluster the setup. It’s also the default set label by the operator, this should find all cluster instances.
# (2) This namespaceSelector explicitly instructs the PodMonitor to search in all namespaces. Without a namespaceSelector, the PodMonitor would only look in the same namespace. You an also provide a list of namespaces if you prefer to be more selective.
# (3) This port name, is from the sidecar container explicitly configured in the postgres-operator configuration above, that is now deployed with every postgresql cluster.
# (4) This port is from Patroni and provides additional metrics regarding the cluster status, such as the current leader/replica situation and should help to debug potential replication problems.
# (5) podTargetLabels instructs Prometheus to collect the Kubernetes pod labels and add them to the metrics collected from the scraped exporters. This is useful to identify your different clusters in dashboards and general queries.

# Reference:
# https://shivering-isles.com/2022/04/postgres-operator-with-monitoring
17 changes: 17 additions & 0 deletions terraform/deployments/releases/kube-prometheus-stack.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
resource "helm_release" "kube-prom-stack" {
name = "kube-prom-stack"
repository = "https://prometheus-community.github.io/helm-charts"
chart = "kube-prometheus-stack"
namespace = "monitoring"
create_namespace = true
version = "55.1.0"
values = [
file("${path.module}/kube-prometheus-stack/kube-prometheus-stack-values.yaml")
]
}

resource "helm_release" "custom_monitoring" {
name = "custom-monitoring" # Setting up our own custom monitoring configuration
chart = "${path.module}/../../../helm/monitoring"
depends_on = [helm_release.kube-prom-stack]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
defaultRules:
create: true
alertmanager:
enabled: true
grafana:
enabled: true
adminPassword: prom-operator
persistence:
enabled: true
storageClassName: ebs-sc
accessModes:
- ReadWriteOnce
size: 5Gi
prometheusOperator:
enabled: true
prometheus:
enabled: true
storageSpec:
volumeClaimTemplate:
spec:
storageClassName: ebs-sc
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi

0 comments on commit 86b7f64

Please sign in to comment.