Skip to content

Commit

Permalink
Merge pull request #1128 from input-output-hk/jpraynaud/1122-ingest-m…
Browse files Browse the repository at this point in the history
…etrics-logs-in-grafana

Ingest metrics/logs in Grafana
  • Loading branch information
jpraynaud authored Aug 3, 2023
2 parents 1853b2f + 91c4d3e commit d4ac66d
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 11 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,14 @@ jobs:
ERA_READER_SECRET_KEY: ${{ secrets.ERA_READER_SECRET_KEY }}
PROMETHEUS_AUTH_USERNAME: ${{ secrets.PROMETHEUS_AUTH_USERNAME }}
PROMETHEUS_AUTH_PASSWORD: ${{ secrets.PROMETHEUS_AUTH_PASSWORD }}
PROMETHEUS_INGEST_HOST: ${{ vars.PROMETHEUS_INGEST_HOST }}
PROMETHEUS_INGEST_USERNAME: ${{ secrets.PROMETHEUS_INGEST_USERNAME }}
PROMETHEUS_INGEST_PASSWORD: ${{ secrets.PROMETHEUS_INGEST_PASSWORD }}
LOKI_AUTH_USERNAME: ${{ secrets.LOKI_AUTH_USERNAME }}
LOKI_AUTH_PASSWORD: ${{ secrets.LOKI_AUTH_PASSWORD }}
LOKI_INGEST_HOST: ${{ vars.LOKI_INGEST_HOST }}
LOKI_INGEST_USERNAME: ${{ secrets.LOKI_INGEST_USERNAME }}
LOKI_INGEST_PASSWORD: ${{ secrets.LOKI_INGEST_PASSWORD }}

defaults:
run:
Expand Down Expand Up @@ -496,8 +502,14 @@ jobs:
mithril_signers = ${{ matrix.mithril_signers }}
prometheus_auth_username = "${{ env.PROMETHEUS_AUTH_USERNAME }}"
prometheus_auth_password = "${{ env.PROMETHEUS_AUTH_PASSWORD }}"
prometheus_ingest_host = "${{ env.PROMETHEUS_INGEST_HOST }}"
prometheus_ingest_username = "${{ env.PROMETHEUS_INGEST_USERNAME }}"
prometheus_ingest_password = "${{ env.PROMETHEUS_INGEST_PASSWORD }}"
loki_auth_username = "${{ env.LOKI_AUTH_USERNAME }}"
loki_auth_password = "${{ env.LOKI_AUTH_PASSWORD }}"
loki_ingest_host = "${{ env.LOKI_INGEST_HOST }}"
loki_ingest_username = "${{ env.LOKI_INGEST_USERNAME }}"
loki_ingest_password = "${{ env.LOKI_INGEST_PASSWORD }}"
EOF
terraform fmt ./env.variables.tfvars
cat ./env.variables.tfvars
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,14 @@ jobs:
ERA_READER_SECRET_KEY: ${{ secrets.ERA_READER_SECRET_KEY }}
PROMETHEUS_AUTH_USERNAME: ${{ secrets.PROMETHEUS_AUTH_USERNAME }}
PROMETHEUS_AUTH_PASSWORD: ${{ secrets.PROMETHEUS_AUTH_PASSWORD }}
PROMETHEUS_INGEST_HOST: ${{ vars.PROMETHEUS_INGEST_HOST }}
PROMETHEUS_INGEST_USERNAME: ${{ secrets.PROMETHEUS_INGEST_USERNAME }}
PROMETHEUS_INGEST_PASSWORD: ${{ secrets.PROMETHEUS_INGEST_PASSWORD }}
LOKI_AUTH_USERNAME: ${{ secrets.LOKI_AUTH_USERNAME }}
LOKI_AUTH_PASSWORD: ${{ secrets.LOKI_AUTH_PASSWORD }}
LOKI_INGEST_HOST: ${{ vars.LOKI_INGEST_HOST }}
LOKI_INGEST_USERNAME: ${{ secrets.LOKI_INGEST_USERNAME }}
LOKI_INGEST_PASSWORD: ${{ secrets.LOKI_INGEST_PASSWORD }}

defaults:
run:
Expand Down Expand Up @@ -224,8 +230,14 @@ jobs:
mithril_signers = ${{ matrix.mithril_signers }}
prometheus_auth_username = "${{ env.PROMETHEUS_AUTH_USERNAME }}"
prometheus_auth_password = "${{ env.PROMETHEUS_AUTH_PASSWORD }}"
prometheus_ingest_host = "${{ env.PROMETHEUS_INGEST_HOST }}"
prometheus_ingest_username = "${{ env.PROMETHEUS_INGEST_USERNAME }}"
prometheus_ingest_password = "${{ env.PROMETHEUS_INGEST_PASSWORD }}"
loki_auth_username = "${{ env.LOKI_AUTH_USERNAME }}"
loki_auth_password = "${{ env.LOKI_AUTH_PASSWORD }}"
loki_ingest_host = "${{ env.LOKI_INGEST_HOST }}"
loki_ingest_username = "${{ env.LOKI_INGEST_USERNAME }}"
loki_ingest_password = "${{ env.LOKI_INGEST_PASSWORD }}"
EOF
terraform fmt ./env.variables.tfvars
cat ./env.variables.tfvars
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,14 @@ jobs:
ERA_READER_SECRET_KEY: ${{ secrets.ERA_READER_SECRET_KEY }}
PROMETHEUS_AUTH_USERNAME: ${{ secrets.PROMETHEUS_AUTH_USERNAME }}
PROMETHEUS_AUTH_PASSWORD: ${{ secrets.PROMETHEUS_AUTH_PASSWORD }}
PROMETHEUS_INGEST_HOST: ${{ vars.PROMETHEUS_INGEST_HOST }}
PROMETHEUS_INGEST_USERNAME: ${{ secrets.PROMETHEUS_INGEST_USERNAME }}
PROMETHEUS_INGEST_PASSWORD: ${{ secrets.PROMETHEUS_INGEST_PASSWORD }}
LOKI_AUTH_USERNAME: ${{ secrets.LOKI_AUTH_USERNAME }}
LOKI_AUTH_PASSWORD: ${{ secrets.LOKI_AUTH_PASSWORD }}
LOKI_INGEST_HOST: ${{ vars.LOKI_INGEST_HOST }}
LOKI_INGEST_USERNAME: ${{ secrets.LOKI_INGEST_USERNAME }}
LOKI_INGEST_PASSWORD: ${{ secrets.LOKI_INGEST_PASSWORD }}

defaults:
run:
Expand Down Expand Up @@ -217,8 +223,14 @@ jobs:
mithril_signers = ${{ matrix.mithril_signers }}
prometheus_auth_username = "${{ env.PROMETHEUS_AUTH_USERNAME }}"
prometheus_auth_password = "${{ env.PROMETHEUS_AUTH_PASSWORD }}"
prometheus_ingest_host = "${{ env.PROMETHEUS_INGEST_HOST }}"
prometheus_ingest_username = "${{ env.PROMETHEUS_INGEST_USERNAME }}"
prometheus_ingest_password = "${{ env.PROMETHEUS_INGEST_PASSWORD }}"
loki_auth_username = "${{ env.LOKI_AUTH_USERNAME }}"
loki_auth_password = "${{ env.LOKI_AUTH_PASSWORD }}"
loki_ingest_host = "${{ env.LOKI_INGEST_HOST }}"
loki_ingest_username = "${{ env.LOKI_INGEST_USERNAME }}"
loki_ingest_password = "${{ env.LOKI_INGEST_PASSWORD }}"
EOF
terraform fmt ./env.variables.tfvars
cat ./env.variables.tfvars
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,3 @@ scrape_configs:
file_sd_configs:
- files:
- 'cardano.json'


Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ server:
positions:
filename: /tmp/positions.yaml

clients:
- url: http://loki:3100/loki/api/v1/push

scrape_configs:
- job_name: system
static_configs:
Expand Down Expand Up @@ -49,4 +46,7 @@ scrape_configs:
image_id:
container_id:
- output:
source: output
source: output

clients:
- url: http://loki:3100/loki/api/v1/push
2 changes: 1 addition & 1 deletion mithril-infra/assets/infra.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.9
0.1.10
27 changes: 27 additions & 0 deletions mithril-infra/mithril.monitoring.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@ resource "null_resource" "mithril_monitoring" {
"mkdir -p /home/curry/data/monitoring/prometheus",
"mkdir -p /home/curry/data/monitoring/loki",
<<-EOT
set -e
# Copy prometheus base configuration
cp /home/curry/docker/prometheus/prometheus-base.yml /home/curry/docker/prometheus/prometheus.yml
# Setup prometheus remote write
if [ -n "${var.prometheus_ingest_host}" ] ; then
cat >> /home/curry/docker/prometheus/prometheus.yml << EOF
remote_write:
- url: https://${var.prometheus_ingest_host}/api/prom/push
basic_auth:
username: ${var.prometheus_ingest_username}
password: ${var.prometheus_ingest_password}
EOF
fi
# Setup prometheus targets configuration for Cardano nodes
CARDANO_NODES=$(docker ps --format='{{.Names}}:12798,' | grep "cardano-node" | sort | tr -d '\n\t\r ' | sed 's/.$//')
cat /home/curry/docker/prometheus/cardano.json | jq --arg CARDANO_NODES "$CARDANO_NODES" '. += [{
Expand All @@ -38,6 +52,19 @@ cat /home/curry/docker/prometheus/cardano.json | jq --arg CARDANO_NODES "$CARDAN
}]' | jq '. | map(try(.targets |= split(",")) // .)' > /home/curry/docker/prometheus/cardano.json.new
rm -f /home/curry/docker/prometheus/cardano.json
mv /home/curry/docker/prometheus/cardano.json.new docker/prometheus/cardano.json
EOT
,
<<-EOT
set -e
# Copy promtail base configuration
cp /home/curry/docker/promtail/promtail-config-base.yml /home/curry/docker/promtail/promtail-config.yml
# Setup promtail remote client
if [ -n "${var.loki_ingest_host}" ] ; then
cat >> /home/curry/docker/promtail/promtail-config.yml << EOF
- url: https://${var.loki_ingest_username}:${var.loki_ingest_password}@${var.loki_ingest_host}/loki/api/v1/push
EOF
fi
EOT
]
}
Expand Down
44 changes: 40 additions & 4 deletions mithril-infra/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -174,25 +174,61 @@ variable "mithril_aggregator_auth_password" {

variable "prometheus_auth_username" {
type = string
description = "The username for authentication on prometheus"
description = "The username for authentication on local prometheus endpoint"
default = ""
}

variable "prometheus_auth_password" {
type = string
description = "The password for authentication on prometheus"
description = "The password for authentication on local prometheus endpoint"
default = ""
}

variable "prometheus_ingest_host" {
type = string
description = "The host to ingest on remote prometheus endpoint"
default = ""
}

variable "prometheus_ingest_username" {
type = string
description = "The username to ingest on remote prometheus endpoint"
default = ""
}

variable "prometheus_ingest_password" {
type = string
description = "The password to ingest on remote prometheus endpoint"
default = ""
}

variable "loki_auth_username" {
type = string
description = "The username for authentication on loki"
description = "The username for authentication on local loki endpoint"
default = ""
}

variable "loki_auth_password" {
type = string
description = "The password for authentication on loki"
description = "The password for authentication on local loki endpoint"
default = ""
}

variable "loki_ingest_host" {
type = string
description = "The host to ingest on remote loki endpoint"
default = ""
}

variable "loki_ingest_username" {
type = string
description = "The username to ingest on remote loki endpoint"
default = ""
}

variable "loki_ingest_password" {
type = string
description = "The password to ingest on remote loki endpoint"
default = ""
}

Expand Down

0 comments on commit d4ac66d

Please sign in to comment.