Skip to content

grafana alloy integration with loki #82

New issue

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

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

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
85 changes: 85 additions & 0 deletions examples/complete/helm/alloy-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
alloy:
configMap:
create: true
content: |
logging {
level = "info"
format = "logfmt"
}

loki.write "default" {
endpoint {
url = "http://loki.monitoring.svc.cluster.local:3100/loki/api/v1/push"
}
}

discovery.kubernetes "pod" {
role = "pod"
}

discovery.relabel "pod_logs" {
targets = discovery.kubernetes.pod.targets

rule {
source_labels = ["__meta_kubernetes_namespace"]
action = "replace"
target_label = "namespace"
}

rule {
source_labels = ["__meta_kubernetes_pod_name"]
action = "replace"
target_label = "pod"
}

rule {
source_labels = ["__meta_kubernetes_pod_container_name"]
action = "replace"
target_label = "container"
}

rule {
source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_name"]
action = "replace"
target_label = "app"
}

rule {
source_labels = ["__meta_kubernetes_namespace", "__meta_kubernetes_pod_container_name"]
action = "replace"
target_label = "job"
separator = "/"
replacement = "$1"
}

rule {
source_labels = ["__meta_kubernetes_pod_uid", "__meta_kubernetes_pod_container_name"]
action = "replace"
target_label = "__path__"
separator = "/"
replacement = "/var/log/pods/$1/$2/*.log"
}

rule {
source_labels = ["__meta_kubernetes_pod_container_id"]
action = "replace"
target_label = "container_runtime"
regex = "^(\\S+):\\/\\/.+$"
replacement = "$1"
}
}

loki.source.kubernetes "pod_logs" {
targets = discovery.relabel.pod_logs.output
forward_to = [loki.process.pod_logs.receiver]
}

loki.process "pod_logs" {
stage.static_labels {
values = {
cluster = "stage-pvc",
}
}

forward_to = [loki.write.default.receiver]
}
1 change: 1 addition & 0 deletions examples/complete/helm/loki.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ loki:
size: "50Gi"

promtail:
enabled: false
config:
snippets:
pipelineStages:
Expand Down
21 changes: 0 additions & 21 deletions examples/complete/helm/promtail.yaml

This file was deleted.

21 changes: 11 additions & 10 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,31 @@ module "pgl" {
version = "3.1.0"
cluster_name = ""
kube_prometheus_stack_enabled = true
loki_enabled = false
loki_scalable_enabled = true
grafana_mimir_enabled = true
loki_enabled = true
grafana_alloy_enabled = true
loki_scalable_enabled = false
grafana_mimir_enabled = false
cloudwatch_enabled = true
tempo_enabled = false
deployment_config = {
hostname = "grafana.squareops.com"
hostname = "grafana-alloy.rnd.squareops.in"
storage_class_name = "infra-service-sc"
prometheus_values_yaml = file("./helm/prometheus.yaml")
loki_values_yaml = file("./helm/loki.yaml")
alloy_values_yaml = file("./helm/alloy-values.yaml")
blackbox_values_yaml = file("./helm/blackbox.yaml")
grafana_mimir_values_yaml = file("./helm/mimir.yaml")
tempo_values_yaml = file("./helm/tempo.yaml")
dashboard_refresh_interval = ""
dashboard_refresh_interval = "120s"
grafana_enabled = true
prometheus_hostname = "prometheus.com"
prometheus_hostname = "prometheus-alloy.rnd.squareops.in"
prometheus_internal_ingress_enabled = false
grafana_ingress_load_balancer = "nlb" ##Choose your load balancer type (e.g., NLB or ALB). If using ALB, ensure you provide the ACM certificate ARN for SSL.
ingress_class_name = "nginx" # enter ingress class name according to your requirement (example: "nginx", "internal-ingress", "private-nginx")
alb_acm_certificate_arn = "" #"arn:aws:acm:${local.region}:444455556666:certificate/certificate_ID"
private_alb_enabled = false # Set to true, when wanted to deploy PGL on ALB internal
loki_internal_ingress_enabled = false
loki_hostname = "loki.com"
loki_hostname = "loki-alloy.rnd.squareops.in"
mimir_s3_bucket_config = {
s3_bucket_name = "${local.environment}-${local.name}-mimir-bucket"
versioning_enabled = "false"
Expand All @@ -52,9 +54,8 @@ module "pgl" {
versioning_enabled = "false"
s3_bucket_region = "${local.region}"
}
promtail_config = {
promtail_version = "6.16.3"
promtail_values = file("./helm/promtail.yaml")
alloy_config = {
alloy_values = file("./helm/alloy-values.yaml")
}
tempo_config = {
s3_bucket_name = "${local.environment}-${local.name}-tempo-skaf"
Expand Down
2 changes: 1 addition & 1 deletion grafana/dashboards/analytics_nginx_logs.json
Original file line number Diff line number Diff line change
Expand Up @@ -2019,4 +2019,4 @@
"uid": "fgc-nginx-web-analytics",
"version": 3,
"weekStart": ""
}
}
2 changes: 1 addition & 1 deletion grafana/dashboards/ingress_nginx.json
Original file line number Diff line number Diff line change
Expand Up @@ -2366,4 +2366,4 @@
"uid": "k8s-nginx-ingress-prometheus-ng",
"version": 5,
"weekStart": ""
}
}
2 changes: 1 addition & 1 deletion grafana/dashboards/k8s_view_namespace.json
Original file line number Diff line number Diff line change
Expand Up @@ -2304,4 +2304,4 @@
"uid": "k8s_views_ns",
"version": 35,
"weekStart": ""
}
}
2 changes: 1 addition & 1 deletion grafana/dashboards/k8s_view_pods.json
Original file line number Diff line number Diff line change
Expand Up @@ -2696,4 +2696,4 @@
"uid": "k8s_views_pods",
"version": 28,
"weekStart": ""
}
}
2 changes: 1 addition & 1 deletion grafana/dashboards/nodegroup.json
Original file line number Diff line number Diff line change
Expand Up @@ -1371,4 +1371,4 @@
"uid": "K8s-CR-Nodesgroups",
"version": 7,
"weekStart": ""
}
}
Loading