Skip to content

Commit

Permalink
feat(o11y): collect Postgres metrics from staging, and prod
Browse files Browse the repository at this point in the history
Referenced `Secret`s have not been committed, because we don't yet use a secret encryption tool like `sops`, or `git-crypt`.

Signed-off-by: Siddhesh Mhadnak <[email protected]>
  • Loading branch information
sid-maddy committed Sep 1, 2024
1 parent e4f6d7b commit 9d18d81
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 4 deletions.
79 changes: 79 additions & 0 deletions kubernetes/chart/values/o11y/vipyrsec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ ingress-nginx:
loki:
enabled: true

# annotations:
# cert-manager.io/cluster-issuer: letsencrypt

# ingress:
# tls:
# - hosts:
# - loki.vipyrsec.com
# secretName: loki-tls

alloy:
enabled: true

Expand Down Expand Up @@ -80,6 +89,24 @@ alloy:
prometheus.exporter.cadvisor "local" { }
remote.kubernetes.secret "postgres_staging" {
namespace = "postgres"
name = "staging"
}
prometheus.exporter.postgres "staging" {
data_source_names = [remote.kubernetes.secret.postgres_staging.data.dsn]
}
remote.kubernetes.secret "postgres_prod" {
namespace = "postgres"
name = "prod"
}
prometheus.exporter.postgres "prod" {
data_source_names = [remote.kubernetes.secret.postgres_prod.data.dsn]
}
prometheus.scrape "self" {
targets = prometheus.exporter.self.local.targets
forward_to = [prometheus.relabel.tagged.receiver]
Expand All @@ -100,6 +127,36 @@ alloy:
forward_to = [prometheus.relabel.tagged.receiver]
}
prometheus.scrape "postgres_staging" {
targets = prometheus.exporter.postgres.staging.targets
forward_to = [prometheus.relabel.tagged_staging.receiver]
}
prometheus.scrape "postgres_staging_do" {
targets = [{"__address__" = remote.kubernetes.secret.postgres_staging.data.metrics_url}]
forward_to = [prometheus.relabel.tagged_staging.receiver]
basic_auth {
username = remote.kubernetes.secret.postgres_staging.data.metrics_username
password = remote.kubernetes.secret.postgres_staging.data.metrics_password
}
}
prometheus.scrape "postgres_prod" {
targets = prometheus.exporter.postgres.prod.targets
forward_to = [prometheus.relabel.tagged_prod.receiver]
}
prometheus.scrape "postgres_prod_do" {
targets = [{"__address__" = remote.kubernetes.secret.postgres_prod.data.metrics_url}]
forward_to = [prometheus.relabel.tagged_prod.receiver]
basic_auth {
username = remote.kubernetes.secret.postgres_prod.data.metrics_username
password = remote.kubernetes.secret.postgres_prod.data.metrics_password
}
}
prometheus.relabel "tagged" {
rule {
source_labels = ["__address__"]
Expand All @@ -111,6 +168,28 @@ alloy:
forward_to = [prometheus.remote_write.o11y.receiver]
}
prometheus.relabel "tagged_staging" {
rule {
source_labels = ["__address__"]
regex = ".*"
replacement = "staging"
target_label = "cluster"
}
forward_to = [prometheus.remote_write.o11y.receiver]
}
prometheus.relabel "tagged_prod" {
rule {
source_labels = ["__address__"]
regex = ".*"
replacement = "prod"
target_label = "cluster"
}
forward_to = [prometheus.remote_write.o11y.receiver]
}
prometheus.remote_write "o11y" {
endpoint {
url = "http://prometheus.prometheus.svc.cluster.local:9090/api/v1/write"
Expand Down
4 changes: 2 additions & 2 deletions kubernetes/chart/values/prod/vipyrsec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ alloy:
loki.write "o11y" {
endpoint {
url = "http://loki.vipyrsec.com/loki/api/v1/push"
url = "http://loki.vipyrsec.com:30080/loki/api/v1/push"
}
}
Expand Down Expand Up @@ -102,6 +102,6 @@ alloy:
prometheus.remote_write "o11y" {
endpoint {
url = "http://prom.vipyrsec.com/api/v1/write"
url = "http://prom.vipyrsec.com:30080/api/v1/write"
}
}
4 changes: 2 additions & 2 deletions kubernetes/chart/values/staging/vipyrsec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ alloy:
loki.write "o11y" {
endpoint {
url = "http://loki.vipyrsec.com/loki/api/v1/push"
url = "http://loki.vipyrsec.com:30080/loki/api/v1/push"
}
}
Expand Down Expand Up @@ -102,6 +102,6 @@ alloy:
prometheus.remote_write "o11y" {
endpoint {
url = "http://prom.vipyrsec.com/api/v1/write"
url = "http://prom.vipyrsec.com:30080/api/v1/write"
}
}
6 changes: 6 additions & 0 deletions kubernetes/manifests/postgres/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# postgres

Manifests for Postgres.

> [!NOTE]
> The `Secret`s have not been committed, because we don't yet use a secret encryption tool like `sops`, or `git-crypt`.
6 changes: 6 additions & 0 deletions kubernetes/manifests/postgres/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
apiVersion: v1
kind: Namespace

metadata:
name: postgres

0 comments on commit 9d18d81

Please sign in to comment.