forked from qclaogui/codelab-monitoring
-
Notifications
You must be signed in to change notification settings - Fork 0
/
k8s-all-in-one.yaml
2135 lines (2095 loc) · 93.6 KB
/
k8s-all-in-one.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
apiVersion: v1
kind: Namespace
metadata:
name: logging-system
---
apiVersion: v1
automountServiceAccountToken: true
kind: ServiceAccount
metadata:
labels:
app.kubernetes.io/instance: loki
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: loki
app.kubernetes.io/version: 3.0.0
helm.sh/chart: loki-6.1.0
name: loki
namespace: logging-system
---
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
app.kubernetes.io/instance: alloy
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: alloy
app.kubernetes.io/version: v1.0.0
helm.sh/chart: alloy-0.1.1
name: alloy
namespace: monitoring-system
---
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
app.kubernetes.io/component: mimir
app.kubernetes.io/instance: mimir-monolithic-mode
app.kubernetes.io/managed-by: Kustomize
app.kubernetes.io/name: mimir
app.kubernetes.io/version: 2.11.0
name: mimir
namespace: monitoring-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
app.kubernetes.io/instance: alloy
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: alloy
app.kubernetes.io/version: v1.0.0
helm.sh/chart: alloy-0.1.1
name: alloy
rules:
- apiGroups:
- ""
- discovery.k8s.io
- networking.k8s.io
resources:
- endpoints
- endpointslices
- ingresses
- nodes
- nodes/proxy
- nodes/metrics
- pods
- services
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
- pods
- pods/log
- namespaces
verbs:
- get
- list
- watch
- apiGroups:
- monitoring.grafana.com
resources:
- podlogs
verbs:
- get
- list
- watch
- apiGroups:
- monitoring.coreos.com
resources:
- prometheusrules
verbs:
- get
- list
- watch
- nonResourceURLs:
- /metrics
verbs:
- get
- apiGroups:
- monitoring.coreos.com
resources:
- podmonitors
- servicemonitors
- probes
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
- events
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
- configmaps
- secrets
verbs:
- get
- list
- watch
- apiGroups:
- apps
resources:
- replicasets
verbs:
- get
- list
- watch
- apiGroups:
- extensions
resources:
- replicasets
verbs:
- get
- list
- watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
app.kubernetes.io/instance: loki
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: loki
app.kubernetes.io/version: 3.0.0
helm.sh/chart: loki-6.1.0
name: loki-clusterrole
rules:
- apiGroups:
- ""
resources:
- configmaps
- secrets
verbs:
- get
- watch
- list
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
labels:
app.kubernetes.io/instance: alloy
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: alloy
app.kubernetes.io/version: v1.0.0
helm.sh/chart: alloy-0.1.1
name: alloy
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: alloy
subjects:
- kind: ServiceAccount
name: alloy
namespace: monitoring-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
labels:
app.kubernetes.io/instance: loki
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: loki
app.kubernetes.io/version: 3.0.0
helm.sh/chart: loki-6.1.0
name: loki-clusterrolebinding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: loki-clusterrole
subjects:
- kind: ServiceAccount
name: loki
namespace: logging-system
---
apiVersion: v1
data:
LOKI_COMPACTOR_HOST: loki-backend.logging-system.svc.cluster.local
LOKI_DISTRIBUTOR_HOST: loki-write.logging-system.svc.cluster.local
LOKI_INGESTER_HOST: loki-write.logging-system.svc.cluster.local
LOKI_QUERIER_HOST: loki-read.logging-system.svc.cluster.local
LOKI_QUERY_FRONTEND_HOST: loki-read.logging-system.svc.cluster.local
LOKI_QUERY_SCHEDULER_HOST: loki-read.logging-system.svc.cluster.local
LOKI_RULER_HOST: loki-backend.logging-system.svc.cluster.local
kind: ConfigMap
metadata:
name: nginx-env
namespace: gateway
---
apiVersion: v1
data:
config.yaml: |2
auth_enabled: false
# -reporting.enabled=false
analytics:
reporting_enabled: false
server:
http_listen_port: 3100
grpc_listen_port: 9095
log_level: info
log_format: json
# https://grafana.com/docs/loki/latest/configure/#use-environment-variables-in-the-configuration
common:
compactor_address: http://loki-backend.logging-system.svc.cluster.local:3100
path_prefix: /var/loki
replication_factor: 1
storage:
s3:
bucketnames: loki-data
endpoint: ${LOKI_S3_ENDPOINT:-minio.minio-system.svc.cluster.local:443}
access_key_id: ${LOKI_S3_ACCESS_KEY_ID:-lgtmp}
secret_access_key: ${LOKI_S3_SECRET_ACCESS_KEY:-supersecret}
insecure: ${LOKI_S3_INSECURE:-false}
s3forcepathstyle: true
http_config:
insecure_skip_verify: true
bloom_gateway:
enabled: true
client:
addresses: "dns+loki-backend.logging-system.svc.cluster.local:9095"
cache_results: true
results_cache:
cache:
memcached_client:
addresses: "dns+memcached.memcached-system.svc.cluster.local:11211"
bloom_compactor:
enabled: true
ring:
kvstore:
store: memberlist
frontend:
scheduler_address: query-scheduler-discovery.logging-system.svc.cluster.local:9095
tail_proxy_url: http://loki-querier.logging-system.svc.cluster.local:3100
frontend_worker:
scheduler_address: query-scheduler-discovery.logging-system.svc.cluster.local:9095
index_gateway:
mode: simple
compactor:
working_directory: /tmp/compactor
memberlist:
join_members:
- loki-memberlist.logging-system.svc.cluster.local:7946
query_range:
align_queries_with_step: true
cache_results: true
results_cache:
cache:
memcached_client:
addresses: "dns+memcached.memcached-system.svc.cluster.local:11211"
cache_index_stats_results: true
index_stats_results_cache:
cache:
memcached_client:
addresses: "dns+memcached.memcached-system.svc.cluster.local:11211"
pattern_ingester:
enabled: true
limits_config:
max_global_streams_per_user: 0
ingestion_rate_mb: 50000
ingestion_burst_size_mb: 50000
volume_enabled: true
ruler:
storage:
s3:
bucketnames: loki-ruler
type: s3
runtime_config:
file: /etc/loki/runtime-config/runtime-config.yaml
schema_config:
configs:
- from: "2024-04-08"
index:
period: 24h
prefix: loki_index_
object_store: s3
schema: v13
store: tsdb
storage_config:
tsdb_shipper:
active_index_directory: /var/loki/index
cache_location: /var/loki/cache
index_gateway_client:
server_address: dns+loki-backend-headless.logging-system.svc.cluster.local:9095
chunk_store_config:
chunk_cache_config:
memcached_client:
addresses: "dns+memcached.memcached-system.svc.cluster.local:11211"
kind: ConfigMap
metadata:
name: loki-config-t6t4f6hhcg
namespace: logging-system
---
apiVersion: v1
data:
runtime-config.yaml: |
# This file can be used to set overrides or other runtime config.
overrides:
"fake": # limits for anonymous that the whole cluster enforces
ingestion_rate_mb: 1500000
max_streams_per_user: 100000
max_chunks_per_query: 100000
"anonymous": # limits for anonymous that the whole cluster enforces
ingestion_rate_mb: 1500000
max_streams_per_user: 100000
max_chunks_per_query: 100000
kind: ConfigMap
metadata:
labels:
app.kubernetes.io/instance: loki
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: loki
app.kubernetes.io/version: 3.0.0
helm.sh/chart: loki-6.1.0
name: loki-runtime
namespace: logging-system
---
apiVersion: v1
data:
config.alloy: "logging {\n\tlevel = coalesce(env(\"ALLOY_LOG_LEVEL\"), \"info\")\n\tformat
= \"logfmt\"\n}\n\n/********************************************\n * Grafana LGTMP
Stack Receiver Provider\n ********************************************/\nimport.git
\"provider\" {\n\trepository = \"https://github.com/qclaogui/codelab-monitoring.git\"\n\trevision
\ = \"main\"\n\tpath = \"alloy-modules/provider\"\n\tpull_frequency
= \"24h\"\n}\n\nprovider.self_hosted_stack \"kubernetes\" {\n\tmetrics_endpoint_url
= coalesce(env(\"SELF_HOSTED_METRICS_ENDPOINT_URL\"), \"http://nginx.gateway.svc:8080/api/v1/push\")\n\tlogs_endpoint_url
\ = coalesce(env(\"SELF_HOSTED_LOGS_ENDPOINT_URL\"), \"http://nginx.gateway.svc:3100/loki/api/v1/push\")\n}\n\n/********************************************\n
* Logs\n ********************************************/\nimport.file \"logs\" {\n\tfilename
= coalesce(env(\"ALLOY_MODULES_FOLDER\"), \"/etc/alloy/modules\") + \"/kubernetes/logs\"\n}\n\nlogs.annotations_scrape
\"kubernetes\" {\n\tannotation_prefix = \"logs.grafana.com\"\n\tforward_to =
[logs.keep_labels.kubernetes.receiver]\n}\n\nlogs.keep_labels \"kubernetes\" {\n\tforward_to
= [provider.self_hosted_stack.kubernetes.logs_receiver]\n}\n\n/********************************************\n
* Metrics\n ********************************************/\nimport.file \"metrics\"
{\n\tfilename = coalesce(env(\"ALLOY_MODULES_FOLDER\"), \"/etc/alloy/modules\")
+ \"/kubernetes/metrics\"\n}\n\nmetrics.integrations_scrape \"kubernetes\" {\n\tforward_to
= [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\nmetrics.podmonitors_scrape
\"kubernetes\" {\n\tforward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\nmetrics.servicemonitors_scrape
\"kubernetes\" {\n\tforward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n"
kind: ConfigMap
metadata:
name: alloy-config-8t9d8htff7
namespace: monitoring-system
---
apiVersion: v1
data:
memcached.alloy: "/*\nModule Components: component_memcached\n*/\n\ndeclare \"component_memcached\"
{\n\n\t/*****************************************************************\n\t*
ARGUMENTS\n\t*****************************************************************/\n\targument
\"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected
metrics should be forwarded to\"\n\t}\n\n\targument \"memcached_address\" {\n\t\tcomment
\ = \"address of the Memcached\"\n\t\toptional = true\n\t\tdefault = \"memcached:11211\"\n\t}\n\n\targument
\"memcached_timeout\" {\n\t\tcomment = \"timeout of the Memcached\"\n\t\toptional
= true\n\t\tdefault = \"5s\"\n\t}\n\n\targument \"instance_name\" {\n\t\tcomment
\ = \"instance of the Memcached\"\n\t\toptional = true\n\t}\n\n\targument \"keep_metrics\"
{\n\t\toptional = true\n\t\tdefault = \"(up|memcached_commands_total|memcached_connections_total|memcached_current_bytes|memcached_current_connections|memcached_current_items|memcached_items_evicted_total|memcached_items_total|memcached_max_connections|memcached_read_bytes_total|memcached_up|memcached_uptime_seconds|memcached_version|memcached_written_bytes_total)\"\n\t}\n\n\targument
\"scrape_interval\" {\n\t\tcomment = \"How often to scrape metrics from the targets
(default: 60s)\"\n\t\toptional = true\n\t\tdefault = \"60s\"\n\t}\n\n\targument
\"scrape_timeout\" {\n\t\tcomment = \"How long before a scrape times out (default:
10s)\"\n\t\toptional = true\n\t\tdefault = \"10s\"\n\t}\n\n\t/***************************************************************\n\t*
Integrations Memcached\n\t****************************************************************/\n\t//
https://grafana.com/docs/alloy/latest/reference/components/prometheus.exporter.memcached/\n\tprometheus.exporter.memcached
\"integrations_memcached_exporter\" {\n\t\taddress = argument.memcached_address.value\n\t\ttimeout
= argument.memcached_timeout.value\n\t}\n\n\t/***************************************************************\n\t*
Discovery Relabelings (pre-scrape)\n\t****************************************************************/\n\tdiscovery.relabel
\"integrations_memcached_exporter\" {\n\t\ttargets = prometheus.exporter.memcached.integrations_memcached_exporter.targets\n\n\t\trule
{\n\t\t\ttarget_label = \"job\"\n\t\t\treplacement = \"integrations/kubernetes/memcached\"\n\t\t}\n\n\t\trule
{\n\t\t\ttarget_label = \"instance\"\n\t\t\treplacement = coalesce(argument.instance_name.value,
constants.hostname)\n\t\t}\n\t}\n\n\t/***************************************************************\n\t*
Prometheus Scrape Integrations Targets\n\t****************************************************************/\n\tprometheus.scrape
\"integrations_memcached_exporter\" {\n\t\ttargets = concat(\n\t\t\tdiscovery.relabel.integrations_memcached_exporter.output,\n\t\t)\n\n\t\tenable_protobuf_negotiation
= true\n\t\tscrape_classic_histograms = true\n\n\t\tscrape_interval = argument.scrape_interval.value\n\t\tscrape_timeout
\ = argument.scrape_timeout.value\n\n\t\tclustering {\n\t\t\tenabled = true\n\t\t}\n\n\t\tforward_to
= [prometheus.relabel.integrations_memcached_exporter.receiver]\n\t}\n\n\t/***************************************************************\n\t*
Prometheus Metric Relabelings (post-scrape)\n\t****************************************************************/\n\tprometheus.relabel
\"integrations_memcached_exporter\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\t//
keep only metrics that match the keep_metrics regex\n\t\trule {\n\t\t\tsource_labels
= [\"__name__\"]\n\t\t\tregex = argument.keep_metrics.value\n\t\t\taction
\ = \"keep\"\n\t\t}\n\t}\n}\n"
kind: ConfigMap
metadata:
name: alloy-modules-kubernetes-integrations-9k86fb8hkg
namespace: monitoring-system
---
apiVersion: v1
data:
annotations-scrape.alloy: "/*\nModule Components: annotations_scrape\nDescription:
Scrapes targets for logs based on kubernetes Pod annotations\n\n Annotations:\n
\ logs.grafana.com/ingest: true\n logs.grafana.com/tenant: \"primary\"\n*/\n\ndeclare
\"annotations_scrape\" {\n\n\t/*****************************************************************\n\t*
ARGUMENTS\n\t*****************************************************************/\n\targument
\"forward_to\" {\n\t\tcomment = \"Must be a list(LogsReceiver) where collected
logs should be forwarded to\"\n\t}\n\n\targument \"tenant\" {\n\t\tcomment =
\"The tenant to filter logs to. This does not have to be the tenantId, this is
the value to look for in the logs.agent.grafana.com/tenant annotation, and this
can be a regex.\"\n\t\toptional = true\n\t\tdefault = \".*\"\n\t}\n\n\t// arguments
for kubernetes discovery\n\targument \"namespaces\" {\n\t\tcomment = \"The namespaces
to look for targets in (default: [\\\"kube-system\\\"] is all namespaces)\"\n\t\toptional
= true\n\t}\n\n\targument \"annotation_prefix\" {\n\t\tcomment = \"The annotation_prefix
to use (default: logs.grafana.com)\"\n\t\tdefault = \"logs.grafana.com\"\n\t\toptional
= true\n\t}\n\n\targument \"__sd_annotation\" {\n\t\toptional = true\n\t\tcomment
\ = \"The logic is used to transform the annotation argument into a valid label
name by removing unsupported characters.\"\n\t\tdefault = replace(replace(replace(coalesce(argument.annotation_prefix.value,
\"logs.grafana.com\"), \".\", \"_\"), \"/\", \"_\"), \"-\", \"_\")\n\t}\n\n\t//
find all pods\n\tdiscovery.kubernetes \"annotation_logs\" {\n\t\trole = \"pod\"\n\n\t\tnamespaces
{\n\t\t\tnames = coalesce(argument.namespaces.value, [])\n\t\t}\n\t}\n\n\t// filter
logs by kubernetes annotations\n\tdiscovery.relabel \"annotation_logs_filter\"
{\n\t\ttargets = discovery.kubernetes.annotation_logs.targets\n\n\t\t// allow
pods to declare their logs to be ingested or not, the default is true\n\t\t//
\ i.e. logs.grafana.com/ingest: false\n\t\trule {\n\t\t\taction = \"keep\"\n\t\t\tsource_labels
= [\n\t\t\t\t\"__meta_kubernetes_pod_annotation_\" + argument.__sd_annotation.value
+ \"_scrape\",\n\t\t\t]\n\t\t\tregex = \"^(true|)$\"\n\t\t}\n\n\t\t// allow pods
to declare what tenant their logs should be written to, the following annotation
is supported:\n\t\t// logs.grafana.com/tenant: \"primary\"\n\t\trule {\n\t\t\taction
\ = \"keep\"\n\t\t\tsource_labels = [\n\t\t\t\t\"__meta_kubernetes_pod_annotation_\"
+ argument.__sd_annotation.value + \"_tenant\",\n\t\t\t]\n\t\t\tregex = \"^(\"
+ argument.tenant.value + \")$\"\n\t\t}\n\n\t\t// set the instance label as the
name of the worker node the pod is on\n\t\trule {\n\t\t\taction = \"replace\"\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_node_name\"]\n\t\t\ttarget_label = \"instance\"\n\t\t}\n\n\t\t//
set the namespace label\n\t\trule {\n\t\t\tsource_labels = [\"__meta_kubernetes_namespace\"]\n\t\t\ttarget_label
\ = \"namespace\"\n\t\t}\n\n\t\t// set the pod label\n\t\trule {\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_name\"]\n\t\t\ttarget_label = \"pod\"\n\t\t}\n\n\t\t//
set the container label\n\t\trule {\n\t\t\tsource_labels = [\"__meta_kubernetes_pod_container_name\"]\n\t\t\ttarget_label
\ = \"container\"\n\t\t}\n\n\t\t// set a workload label\n\t\trule {\n\t\t\tsource_labels
= [\n\t\t\t\t\"__meta_kubernetes_pod_controller_kind\",\n\t\t\t\t\"__meta_kubernetes_pod_controller_name\",\n\t\t\t]\n\t\t\tseparator
\ = \"/\"\n\t\t\ttarget_label = \"workload\"\n\t\t}\n\t\t// remove the hash
from the ReplicaSet\n\t\trule {\n\t\t\tsource_labels = [\"workload\"]\n\t\t\tregex
\ = \"(ReplicaSet/.+)-.+\"\n\t\t\ttarget_label = \"workload\"\n\t\t}\n\n\t\t//
set the app name if specified as metadata labels \"app:\" or \"app.kubernetes.io/name:\"
or \"k8s-app:\"\n\t\trule {\n\t\t\taction = \"replace\"\n\t\t\tsource_labels
= [\n\t\t\t\t\"__meta_kubernetes_pod_label_app_kubernetes_io_name\",\n\t\t\t\t\"__meta_kubernetes_pod_label_k8s_app\",\n\t\t\t\t\"__meta_kubernetes_pod_label_app\",\n\t\t\t]\n\t\t\tseparator
\ = \";\"\n\t\t\tregex = \"^(?:;*)?([^;]+).*$\"\n\t\t\treplacement =
\"$1\"\n\t\t\ttarget_label = \"app\"\n\t\t}\n\n\t\t// set the component if specified
as metadata labels \"component:\" or \"app.kubernetes.io/component:\" or \"k8s-component:\"\n\t\trule
{\n\t\t\taction = \"replace\"\n\t\t\tsource_labels = [\n\t\t\t\t\"__meta_kubernetes_pod_label_app_kubernetes_io_component\",\n\t\t\t\t\"__meta_kubernetes_pod_label_k8s_component\",\n\t\t\t\t\"__meta_kubernetes_pod_label_component\",\n\t\t\t]\n\t\t\tregex
\ = \"^(?:;*)?([^;]+).*$\"\n\t\t\treplacement = \"$1\"\n\t\t\ttarget_label
= \"component\"\n\t\t}\n\n\t\t// set the version if specified as metadata labels
\"version:\" or \"app.kubernetes.io/version:\" or \"app_version:\"\n\t\trule {\n\t\t\taction
\ = \"replace\"\n\t\t\tsource_labels = [\n\t\t\t\t\"__meta_kubernetes_pod_label_app_kubernetes_io_version\",\n\t\t\t\t\"__meta_kubernetes_pod_label_version\",\n\t\t\t\t\"__meta_kubernetes_pod_label_app_version\",\n\t\t\t]\n\t\t\tregex
\ = \"^(?:;*)?([^;]+).*$\"\n\t\t\treplacement = \"$1\"\n\t\t\ttarget_label
= \"version\"\n\t\t}\n\n\t\t// set a source label\n\t\trule {\n\t\t\taction =
\"replace\"\n\t\t\treplacement = \"kubernetes\"\n\t\t\ttarget_label = \"source\"\n\t\t}\n\n\t\t//
set the job label to be namespace / friendly pod name\n\t\trule {\n\t\t\taction
\ = \"replace\"\n\t\t\tsource_labels = [\n\t\t\t\t\"workload\",\n\t\t\t\t\"__meta_kubernetes_namespace\",\n\t\t\t]\n\t\t\tregex
\ = \".+\\\\/(.+);(.+)\"\n\t\t\treplacement = \"$2/$1\"\n\t\t\ttarget_label
= \"job\"\n\t\t}\n\n\t\t// make all labels on the pod available to the pipeline
as labels,\n\t\t// they are omitted before write via labelallow unless explicitly
set\n\t\trule {\n\t\t\taction = \"labelmap\"\n\t\t\tregex = \"__meta_kubernetes_pod_label_(.+)\"\n\t\t}\n\n\t\t//
make all annotations on the pod available to the pipeline as labels,\n\t\t// they
are omitted before write via labelallow unless explicitly set\n\t\trule {\n\t\t\taction
= \"labelmap\"\n\t\t\tregex = \"__meta_kubernetes_pod_annotation_(.+)\"\n\t\t}\n\n\t\t//
as a result of kubernetes service discovery for pods, all of the meta data information
is exposed in labels\n\t\t// __meta_kubernetes_pod_*, including __meta_kubernetes_pod_container_id
which can be used to determine what\n\t\t// the pods container runtime is, docker
(docker://...) or containerd (containerd://...) this will inform us\n\t\t// which
parsing stage to use. However, any labels that begin with __* are not passed
to loki.process\n\t\t// (pipeline) stages. Use a relabeling stage to set a label
that can be used a LogQL selector in the stage\n\t\t// below so parsing can be
automatically determined, then drop the label from the loki.process stage.\n\t\t//
set the container runtime as a label\n\t\trule {\n\t\t\taction = \"replace\"\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_container_id\"]\n\t\t\tregex = \"^(\\\\w+):\\\\/\\\\/.+$\"\n\t\t\treplacement
\ = \"$1\"\n\t\t\ttarget_label = \"tmp_container_runtime\"\n\t\t}\n\t}\n\n\tloki.source.kubernetes
\"lsd_kubernetes_logs\" {\n\t\ttargets = discovery.relabel.annotation_logs_filter.output\n\t\tforward_to
= [loki.process.parse.receiver]\n\t}\n\n\t// parse the log based on the container
runtime\n\tloki.process \"parse\" {\n\t\tforward_to = argument.forward_to.value\n\t\t/*******************************************************************************\n\t\t*
\ Container Runtime Parsing\n\t\t********************************************************************************/\n\t\t//
if the label tmp_container_runtime from above is containerd parse using cri\n\t\tstage.match
{\n\t\t\tselector = \"{tmp_container_runtime=\\\"containerd\\\"}\"\n\t\t\t// the
cri processing stage extracts the following k/v pairs: log, stream, time, flags\n\t\t\tstage.cri
{ }\n\n\t\t\t// Set the extract flags and stream values as labels\n\t\t\tstage.labels
{\n\t\t\t\tvalues = {\n\t\t\t\t\tflags = \"\",\n\t\t\t\t\tstream = \"\",\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t//
if the label tmp_container_runtime from above is docker parse using docker\n\t\tstage.match
{\n\t\t\tselector = \"{tmp_container_runtime=\\\"docker\\\"}\"\n\t\t\t// the docker
processing stage extracts the following k/v pairs: log, stream, time\n\t\t\tstage.docker
{ }\n\n\t\t\t// Set the extract stream value as a label\n\t\t\tstage.labels {\n\t\t\t\tvalues
= {\n\t\t\t\t\tstream = \"\",\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// drop the temporary
container runtime label as it is no longer needed\n\t\tstage.label_drop {\n\t\t\tvalues
= [\"tmp_container_runtime\"]\n\t\t}\n\t}\n}\n"
keep-labels.alloy: "/*\nModule Components: keep_labels\nDescription: Pre-defined
set of labels to keep, this stage should always be in-place as the previous relabeing\n
\ stages make every pod label and annotation a label in the pipeline,
which we do not want created\n in Loki as that would have extremely
high-cardinality.\n*/\n\ndeclare \"keep_labels\" {\n\n\t/*****************************************************************\n\t*
ARGUMENTS\n\t*****************************************************************/\n\targument
\"forward_to\" {\n\t\tcomment = \"Must be a list(LogsReceiver) where collected
logs should be forwarded to\"\n\t}\n\n\targument \"keep_labels\" {\n\t\toptional
= true\n\t\tcomment = \"List of labels to keep before the log message is written
to Loki\"\n\t\tdefault = [\n\t\t\t\"app\",\n\t\t\t\"cluster\",\n\t\t\t\"component\",\n\t\t\t\"container\",\n\t\t\t\"env\",\n\t\t\t\"job\",\n\t\t\t\"level\",\n\t\t\t\"namespace\",\n\t\t\t\"region\",\n\t\t\t\"service\",\n\t\t\t\"squad\",\n\t\t\t\"team\",\n\t\t\t\"workload\",\n\t\t]\n\t}\n\n\t/*****************************************************************\n\t*
LOKI PROCESS\n\t*****************************************************************/\n\tloki.process
\"keep_labels\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\t/*\n\t\tAs
all of the pod labels and annotations we transformed into labels in the previous
relabelings to make\n\t\tthem available to the pipeline processing we need to
ensure they are not automatically created in Loki.\n\t\tThis would result in an
extremely high number of labels and values severely impacting query performance.\n\t\tNot
every log has to contain these labels, but this list should reflect the set of
labels that you want\n\t\tto explicitly allow.\n\t\t*/\n\t\tstage.label_keep {\n\t\t\tvalues
= argument.keep_labels.value\n\t\t}\n\t}\n\n\t/*****************************************************************\n\t*
EXPORTS\n\t*****************************************************************/\n\texport
\"receiver\" {\n\t\tvalue = loki.process.keep_labels.receiver\n\t}\n}\n"
kind: ConfigMap
metadata:
name: alloy-modules-kubernetes-logs-d7c756mt2f
namespace: monitoring-system
---
apiVersion: v1
data:
integrations-scrape.alloy: "/*\nModule Components: integrations_scrape\nDescription:
Integrations Module Components Scrape\n\nNote: Every argument except for \"forward_to\"
is optional, and does have a defined default value. However, the values for these\n
\ arguments are not defined using the default = \" ... \" argument syntax,
but rather using the coalesce(argument.value, \" ... \").\n This is because
if the argument passed in from another consuming module is set to null, the default
= \" ... \" syntax will\n does not override the value passed in, where coalesce()
will return the first non-null value.\n*/\n\ndeclare \"integrations_scrape\" {\n\n\t/*****************************************************************\n\t*
ARGUMENTS\n\t*****************************************************************/\n\targument
\"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected
metrics should be forwarded to\"\n\t}\n\n\targument \"name\" {\n\t\tcomment =
\"Name of the integrations config\"\n\t\toptional = true\n\t\tdefault = \"alloy-integrations\"\n\t}\n\n\targument
\"namespace\" {\n\t\tcomment = \"Namespace of the integrations config\"\n\t\toptional
= true\n\t\tdefault = \"default\"\n\t}\n\n\t/*****************************************************************\n\t*
Import Integrations Components\n\t*****************************************************************/\n\t//
integrate components local files\n\timport.file \"integrate\" {\n\t\tfilename
= coalesce(env(\"ALLOY_MODULES_FOLDER\"), \"/etc/alloy/modules\") + \"/kubernetes/integrations\"\n\t}\n\n\t//
// integrate components kubernetes configmap\n\t// remote.kubernetes.configmap
\"integrations\" {\n\t// \tname = argument.name.value\n\t// \tnamespace =
argument.namespace.value\n\t// }\n\t// import.string \"integrate\" {\n\t// \tcontent
= remote.kubernetes.configmap.integrations.data[\"memcached.alloy\"]\n\t// }\n\n\t/*****************************************************************\n\t*
Memcached Integrations\n\t*****************************************************************/\n\tintegrate.component_memcached
\"primary\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tinstance_name
\ = \"primary\"\n\t\tmemcached_address = \"memcached.memcached-system.svc.cluster.local:11211\"\n\t\tmemcached_timeout
= \"5s\"\n\t}\n}\n"
podmonitors-scrape.alloy: "/*\nModule Components: podmonitors_scrape\nDescription:
Scrapes targets for metrics based on prometheus.operator.podmonitors\n*/\n\ndeclare
\"podmonitors_scrape\" {\n\n\t/*****************************************************************\n\t*
ARGUMENTS\n\t*****************************************************************/\n\targument
\"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected
metrics should be forwarded to\"\n\t\toptional = false\n\t}\n\n\t/*****************************************************************\n\t*
Kubernetes Auto Scrape PodMonitors\n\t*****************************************************************/\n\tprometheus.operator.podmonitors
\"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tclustering {\n\t\t\tenabled
= true\n\t\t}\n\n\t\t// selector {\n\t\t// \tmatch_expression {\n\t\t// \t\tkey
\ = \"team\"\n\t\t// \t\toperator = \"In\"\n\t\t// \t\tvalues = [\"team-infra\"]\n\t\t//
\t}\n\t\t// }\n\t}\n}\n"
servicemonitors-scrape.alloy: "/*\nModule Components: servicemonitors_scrape\nDescription:
Scrapes targets for metrics based on prometheus.operator.servicemonitors\n*/\n\ndeclare
\"servicemonitors_scrape\" {\n\n\t/*****************************************************************\n\t*
ARGUMENTS\n\t*****************************************************************/\n\targument
\"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected
metrics should be forwarded to\"\n\t\toptional = false\n\t}\n\n\t/*****************************************************************\n\t*
Kubernetes Auto Scrape ServiceMonitors\n\t*****************************************************************/\n\tprometheus.operator.servicemonitors
\"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tclustering {\n\t\t\tenabled
= true\n\t\t}\n\t}\n}\n"
kind: ConfigMap
metadata:
name: alloy-modules-kubernetes-metrics-tf9cd8b6bg
namespace: monitoring-system
---
apiVersion: v1
data:
annotations-scrape.alloy: "/*\nModule Components: annotations_scrape\nDescription:
Scrapes targets for metrics based on kubernetes Pod annotations\n\n*/\n\ndeclare
\"annotations_scrape\" {\n\n\t/*****************************************************************\n\t*
ARGUMENTS\n\t*****************************************************************/\n\targument
\"forward_to\" {\n\t\tcomment = \"Must be a list(ProfilessReceiver) where collected
logs should be forwarded to\"\n\t}\n\n\tdiscovery.kubernetes \"pyroscope_kubernetes\"
{\n\t\trole = \"pod\"\n\t}\n\n\t// The default scrape config allows to define
annotations based scraping.\n\t//\n\t// For example the following annotations:\n\t//\n\t//
```\n\t// profiles.grafana.com/memory.scrape: \"true\"\n\t// profiles.grafana.com/memory.port:
\"8080\"\n\t// profiles.grafana.com/cpu.scrape: \"true\"\n\t// profiles.grafana.com/cpu.port:
\"8080\"\n\t// profiles.grafana.com/goroutine.scrape: \"true\"\n\t// profiles.grafana.com/goroutine.port:
\"8080\"\n\t// ```\n\t//\n\t// will scrape the `memory`, `cpu` and `goroutine`
profiles from the `8080` port of the pod.\n\t//\n\t// For more information see
https://grafana.com/docs/phlare/latest/operators-guide/deploy-kubernetes/#optional-scrape-your-own-workloads-profiles\n\tdiscovery.relabel
\"kubernetes_pods\" {\n\t\ttargets = concat(discovery.kubernetes.pyroscope_kubernetes.targets)\n\n\t\trule
{\n\t\t\taction = \"drop\"\n\t\t\tsource_labels = [\"__meta_kubernetes_pod_phase\"]\n\t\t\tregex
\ = \"Pending|Succeeded|Failed|Completed\"\n\t\t}\n\n\t\trule {\n\t\t\taction
= \"labelmap\"\n\t\t\tregex = \"__meta_kubernetes_pod_label_(.+)\"\n\t\t}\n\n\t\trule
{\n\t\t\taction = \"replace\"\n\t\t\tsource_labels = [\"__meta_kubernetes_namespace\"]\n\t\t\ttarget_label
\ = \"namespace\"\n\t\t}\n\n\t\trule {\n\t\t\taction = \"replace\"\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_name\"]\n\t\t\ttarget_label = \"pod\"\n\t\t}\n\n\t\trule
{\n\t\t\taction = \"replace\"\n\t\t\tsource_labels = [\"__meta_kubernetes_pod_container_name\"]\n\t\t\ttarget_label
\ = \"container\"\n\t\t}\n\t}\n\n\tdiscovery.relabel \"kubernetes_pods_memory_default_name\"
{\n\t\ttargets = concat(discovery.relabel.kubernetes_pods.output)\n\n\t\trule
{\n\t\t\tsource_labels = [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_memory_scrape\"]\n\t\t\taction
\ = \"keep\"\n\t\t\tregex = \"true\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_memory_port_name\"]\n\t\t\taction
\ = \"keep\"\n\t\t\tregex = \"\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_memory_scheme\"]\n\t\t\taction
\ = \"replace\"\n\t\t\tregex = \"(https?)\"\n\t\t\ttarget_label
\ = \"__scheme__\"\n\t\t\treplacement = \"$1\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_memory_path\"]\n\t\t\taction
\ = \"replace\"\n\t\t\tregex = \"(.+)\"\n\t\t\ttarget_label = \"__profile_path__\"\n\t\t\treplacement
\ = \"$1\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels = [\"__address__\", \"__meta_kubernetes_pod_annotation_profiles_grafana_com_memory_port\"]\n\t\t\taction
\ = \"replace\"\n\t\t\tregex = \"(.+?)(?::\\\\d+)?;(\\\\d+)\"\n\t\t\ttarget_label
\ = \"__address__\"\n\t\t\treplacement = \"$1:$2\"\n\t\t}\n\t}\n\n\tdiscovery.relabel
\"kubernetes_pods_memory_custom_name\" {\n\t\ttargets = concat(discovery.relabel.kubernetes_pods.output)\n\n\t\trule
{\n\t\t\tsource_labels = [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_memory_scrape\"]\n\t\t\taction
\ = \"keep\"\n\t\t\tregex = \"true\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_memory_port_name\"]\n\t\t\taction
\ = \"drop\"\n\t\t\tregex = \"\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_container_port_name\"]\n\t\t\ttarget_label = \"__meta_kubernetes_pod_annotation_profiles_grafana_com_memory_port_name\"\n\t\t\taction
\ = \"keepequal\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels = [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_memory_scheme\"]\n\t\t\taction
\ = \"replace\"\n\t\t\tregex = \"(https?)\"\n\t\t\ttarget_label
\ = \"__scheme__\"\n\t\t\treplacement = \"$1\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_memory_path\"]\n\t\t\taction
\ = \"replace\"\n\t\t\tregex = \"(.+)\"\n\t\t\ttarget_label = \"__profile_path__\"\n\t\t\treplacement
\ = \"$1\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels = [\"__address__\", \"__meta_kubernetes_pod_annotation_profiles_grafana_com_memory_port\"]\n\t\t\taction
\ = \"replace\"\n\t\t\tregex = \"(.+?)(?::\\\\d+)?;(\\\\d+)\"\n\t\t\ttarget_label
\ = \"__address__\"\n\t\t\treplacement = \"$1:$2\"\n\t\t}\n\t}\n\n\t/*****************************************************************\n\t*
Kubernetes Pyroscope Scrape Memory\n\t*****************************************************************/\n\tpyroscope.scrape
\"pyroscope_scrape_memory\" {\n\t\tclustering {\n\t\t\tenabled = true\n\t\t}\n\n\t\ttargets
\ = concat(discovery.relabel.kubernetes_pods_memory_default_name.output, discovery.relabel.kubernetes_pods_memory_custom_name.output)\n\t\tforward_to
= argument.forward_to.value\n\n\t\tprofiling_config {\n\t\t\tprofile.memory {\n\t\t\t\tenabled
= true\n\t\t\t}\n\n\t\t\tprofile.process_cpu {\n\t\t\t\tenabled = false\n\t\t\t}\n\n\t\t\tprofile.goroutine
{\n\t\t\t\tenabled = false\n\t\t\t}\n\n\t\t\tprofile.block {\n\t\t\t\tenabled
= false\n\t\t\t}\n\n\t\t\tprofile.mutex {\n\t\t\t\tenabled = false\n\t\t\t}\n\n\t\t\tprofile.fgprof
{\n\t\t\t\tenabled = false\n\t\t\t}\n\t\t}\n\t}\n\n\tdiscovery.relabel \"kubernetes_pods_cpu_default_name\"
{\n\t\ttargets = concat(discovery.relabel.kubernetes_pods.output)\n\n\t\trule
{\n\t\t\tsource_labels = [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_cpu_scrape\"]\n\t\t\taction
\ = \"keep\"\n\t\t\tregex = \"true\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_cpu_port_name\"]\n\t\t\taction
\ = \"keep\"\n\t\t\tregex = \"\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_cpu_scheme\"]\n\t\t\taction
\ = \"replace\"\n\t\t\tregex = \"(https?)\"\n\t\t\ttarget_label
\ = \"__scheme__\"\n\t\t\treplacement = \"$1\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_cpu_path\"]\n\t\t\taction
\ = \"replace\"\n\t\t\tregex = \"(.+)\"\n\t\t\ttarget_label = \"__profile_path__\"\n\t\t\treplacement
\ = \"$1\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels = [\"__address__\", \"__meta_kubernetes_pod_annotation_profiles_grafana_com_cpu_port\"]\n\t\t\taction
\ = \"replace\"\n\t\t\tregex = \"(.+?)(?::\\\\d+)?;(\\\\d+)\"\n\t\t\ttarget_label
\ = \"__address__\"\n\t\t\treplacement = \"$1:$2\"\n\t\t}\n\t}\n\n\tdiscovery.relabel
\"kubernetes_pods_cpu_custom_name\" {\n\t\ttargets = concat(discovery.relabel.kubernetes_pods.output)\n\n\t\trule
{\n\t\t\tsource_labels = [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_cpu_scrape\"]\n\t\t\taction
\ = \"keep\"\n\t\t\tregex = \"true\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_cpu_port_name\"]\n\t\t\taction
\ = \"drop\"\n\t\t\tregex = \"\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_container_port_name\"]\n\t\t\ttarget_label = \"__meta_kubernetes_pod_annotation_profiles_grafana_com_cpu_port_name\"\n\t\t\taction
\ = \"keepequal\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels = [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_cpu_scheme\"]\n\t\t\taction
\ = \"replace\"\n\t\t\tregex = \"(https?)\"\n\t\t\ttarget_label
\ = \"__scheme__\"\n\t\t\treplacement = \"$1\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_cpu_path\"]\n\t\t\taction
\ = \"replace\"\n\t\t\tregex = \"(.+)\"\n\t\t\ttarget_label = \"__profile_path__\"\n\t\t\treplacement
\ = \"$1\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels = [\"__address__\", \"__meta_kubernetes_pod_annotation_profiles_grafana_com_cpu_port\"]\n\t\t\taction
\ = \"replace\"\n\t\t\tregex = \"(.+?)(?::\\\\d+)?;(\\\\d+)\"\n\t\t\ttarget_label
\ = \"__address__\"\n\t\t\treplacement = \"$1:$2\"\n\t\t}\n\t}\n\n\t/*****************************************************************\n\t*
Kubernetes Pyroscope Scrape CPU\n\t*****************************************************************/\n\tpyroscope.scrape
\"pyroscope_scrape_cpu\" {\n\t\tclustering {\n\t\t\tenabled = true\n\t\t}\n\n\t\ttargets
\ = concat(discovery.relabel.kubernetes_pods_cpu_default_name.output, discovery.relabel.kubernetes_pods_cpu_custom_name.output)\n\t\tforward_to
= argument.forward_to.value\n\n\t\tprofiling_config {\n\t\t\tprofile.memory {\n\t\t\t\tenabled
= false\n\t\t\t}\n\n\t\t\tprofile.process_cpu {\n\t\t\t\tenabled = true\n\t\t\t}\n\n\t\t\tprofile.goroutine
{\n\t\t\t\tenabled = false\n\t\t\t}\n\n\t\t\tprofile.block {\n\t\t\t\tenabled
= false\n\t\t\t}\n\n\t\t\tprofile.mutex {\n\t\t\t\tenabled = false\n\t\t\t}\n\n\t\t\tprofile.fgprof
{\n\t\t\t\tenabled = false\n\t\t\t}\n\t\t}\n\t}\n\n\tdiscovery.relabel \"kubernetes_pods_goroutine_default_name\"
{\n\t\ttargets = concat(discovery.relabel.kubernetes_pods.output)\n\n\t\trule
{\n\t\t\tsource_labels = [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_goroutine_scrape\"]\n\t\t\taction
\ = \"keep\"\n\t\t\tregex = \"true\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_goroutine_port_name\"]\n\t\t\taction
\ = \"keep\"\n\t\t\tregex = \"\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_goroutine_scheme\"]\n\t\t\taction
\ = \"replace\"\n\t\t\tregex = \"(https?)\"\n\t\t\ttarget_label
\ = \"__scheme__\"\n\t\t\treplacement = \"$1\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_goroutine_path\"]\n\t\t\taction
\ = \"replace\"\n\t\t\tregex = \"(.+)\"\n\t\t\ttarget_label = \"__profile_path__\"\n\t\t\treplacement
\ = \"$1\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels = [\"__address__\", \"__meta_kubernetes_pod_annotation_profiles_grafana_com_goroutine_port\"]\n\t\t\taction
\ = \"replace\"\n\t\t\tregex = \"(.+?)(?::\\\\d+)?;(\\\\d+)\"\n\t\t\ttarget_label
\ = \"__address__\"\n\t\t\treplacement = \"$1:$2\"\n\t\t}\n\t}\n\n\tdiscovery.relabel
\"kubernetes_pods_goroutine_custom_name\" {\n\t\ttargets = concat(discovery.relabel.kubernetes_pods.output)\n\n\t\trule
{\n\t\t\tsource_labels = [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_goroutine_scrape\"]\n\t\t\taction
\ = \"keep\"\n\t\t\tregex = \"true\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_goroutine_port_name\"]\n\t\t\taction
\ = \"drop\"\n\t\t\tregex = \"\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_container_port_name\"]\n\t\t\ttarget_label = \"__meta_kubernetes_pod_annotation_profiles_grafana_com_goroutine_port_name\"\n\t\t\taction
\ = \"keepequal\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels = [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_goroutine_scheme\"]\n\t\t\taction
\ = \"replace\"\n\t\t\tregex = \"(https?)\"\n\t\t\ttarget_label
\ = \"__scheme__\"\n\t\t\treplacement = \"$1\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_goroutine_path\"]\n\t\t\taction
\ = \"replace\"\n\t\t\tregex = \"(.+)\"\n\t\t\ttarget_label = \"__profile_path__\"\n\t\t\treplacement
\ = \"$1\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels = [\"__address__\", \"__meta_kubernetes_pod_annotation_profiles_grafana_com_goroutine_port\"]\n\t\t\taction
\ = \"replace\"\n\t\t\tregex = \"(.+?)(?::\\\\d+)?;(\\\\d+)\"\n\t\t\ttarget_label
\ = \"__address__\"\n\t\t\treplacement = \"$1:$2\"\n\t\t}\n\t}\n\n\t/*****************************************************************\n\t*
Kubernetes Pyroscope Scrape Goroutine\n\t*****************************************************************/\n\tpyroscope.scrape
\"pyroscope_scrape_goroutine\" {\n\t\tclustering {\n\t\t\tenabled = true\n\t\t}\n\n\t\ttargets
\ = concat(discovery.relabel.kubernetes_pods_goroutine_default_name.output,
discovery.relabel.kubernetes_pods_goroutine_custom_name.output)\n\t\tforward_to
= argument.forward_to.value\n\n\t\tprofiling_config {\n\t\t\tprofile.memory {\n\t\t\t\tenabled
= false\n\t\t\t}\n\n\t\t\tprofile.process_cpu {\n\t\t\t\tenabled = false\n\t\t\t}\n\n\t\t\tprofile.goroutine
{\n\t\t\t\tenabled = true\n\t\t\t}\n\n\t\t\tprofile.block {\n\t\t\t\tenabled =
false\n\t\t\t}\n\n\t\t\tprofile.mutex {\n\t\t\t\tenabled = false\n\t\t\t}\n\n\t\t\tprofile.fgprof
{\n\t\t\t\tenabled = false\n\t\t\t}\n\t\t}\n\t}\n\n\tdiscovery.relabel \"kubernetes_pods_block_default_name\"
{\n\t\ttargets = concat(discovery.relabel.kubernetes_pods.output)\n\n\t\trule
{\n\t\t\tsource_labels = [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_block_scrape\"]\n\t\t\taction
\ = \"keep\"\n\t\t\tregex = \"true\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_block_port_name\"]\n\t\t\taction
\ = \"keep\"\n\t\t\tregex = \"\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_block_scheme\"]\n\t\t\taction
\ = \"replace\"\n\t\t\tregex = \"(https?)\"\n\t\t\ttarget_label
\ = \"__scheme__\"\n\t\t\treplacement = \"$1\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_block_path\"]\n\t\t\taction
\ = \"replace\"\n\t\t\tregex = \"(.+)\"\n\t\t\ttarget_label = \"__profile_path__\"\n\t\t\treplacement
\ = \"$1\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels = [\"__address__\", \"__meta_kubernetes_pod_annotation_profiles_grafana_com_block_port\"]\n\t\t\taction
\ = \"replace\"\n\t\t\tregex = \"(.+?)(?::\\\\d+)?;(\\\\d+)\"\n\t\t\ttarget_label
\ = \"__address__\"\n\t\t\treplacement = \"$1:$2\"\n\t\t}\n\t}\n\n\tdiscovery.relabel
\"kubernetes_pods_block_custom_name\" {\n\t\ttargets = concat(discovery.relabel.kubernetes_pods.output)\n\n\t\trule
{\n\t\t\tsource_labels = [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_block_scrape\"]\n\t\t\taction
\ = \"keep\"\n\t\t\tregex = \"true\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_block_port_name\"]\n\t\t\taction
\ = \"drop\"\n\t\t\tregex = \"\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_container_port_name\"]\n\t\t\ttarget_label = \"__meta_kubernetes_pod_annotation_profiles_grafana_com_block_port_name\"\n\t\t\taction
\ = \"keepequal\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels = [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_block_scheme\"]\n\t\t\taction
\ = \"replace\"\n\t\t\tregex = \"(https?)\"\n\t\t\ttarget_label
\ = \"__scheme__\"\n\t\t\treplacement = \"$1\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_block_path\"]\n\t\t\taction
\ = \"replace\"\n\t\t\tregex = \"(.+)\"\n\t\t\ttarget_label = \"__profile_path__\"\n\t\t\treplacement
\ = \"$1\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels = [\"__address__\", \"__meta_kubernetes_pod_annotation_profiles_grafana_com_block_port\"]\n\t\t\taction
\ = \"replace\"\n\t\t\tregex = \"(.+?)(?::\\\\d+)?;(\\\\d+)\"\n\t\t\ttarget_label
\ = \"__address__\"\n\t\t\treplacement = \"$1:$2\"\n\t\t}\n\t}\n\n\t/*****************************************************************\n\t*
Kubernetes Pyroscope Scrape Block\n\t*****************************************************************/\n\tpyroscope.scrape
\"pyroscope_scrape_block\" {\n\t\tclustering {\n\t\t\tenabled = true\n\t\t}\n\n\t\ttargets
\ = concat(discovery.relabel.kubernetes_pods_block_default_name.output, discovery.relabel.kubernetes_pods_block_custom_name.output)\n\t\tforward_to
= argument.forward_to.value\n\n\t\tprofiling_config {\n\t\t\tprofile.memory {\n\t\t\t\tenabled
= false\n\t\t\t}\n\n\t\t\tprofile.process_cpu {\n\t\t\t\tenabled = false\n\t\t\t}\n\n\t\t\tprofile.goroutine
{\n\t\t\t\tenabled = false\n\t\t\t}\n\n\t\t\tprofile.block {\n\t\t\t\tenabled
= true\n\t\t\t}\n\n\t\t\tprofile.mutex {\n\t\t\t\tenabled = false\n\t\t\t}\n\n\t\t\tprofile.fgprof
{\n\t\t\t\tenabled = false\n\t\t\t}\n\t\t}\n\t}\n\n\tdiscovery.relabel \"kubernetes_pods_mutex_default_name\"
{\n\t\ttargets = concat(discovery.relabel.kubernetes_pods.output)\n\n\t\trule
{\n\t\t\tsource_labels = [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_mutex_scrape\"]\n\t\t\taction
\ = \"keep\"\n\t\t\tregex = \"true\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_mutex_port_name\"]\n\t\t\taction
\ = \"keep\"\n\t\t\tregex = \"\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_mutex_scheme\"]\n\t\t\taction
\ = \"replace\"\n\t\t\tregex = \"(https?)\"\n\t\t\ttarget_label
\ = \"__scheme__\"\n\t\t\treplacement = \"$1\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_mutex_path\"]\n\t\t\taction
\ = \"replace\"\n\t\t\tregex = \"(.+)\"\n\t\t\ttarget_label = \"__profile_path__\"\n\t\t\treplacement
\ = \"$1\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels = [\"__address__\", \"__meta_kubernetes_pod_annotation_profiles_grafana_com_mutex_port\"]\n\t\t\taction
\ = \"replace\"\n\t\t\tregex = \"(.+?)(?::\\\\d+)?;(\\\\d+)\"\n\t\t\ttarget_label
\ = \"__address__\"\n\t\t\treplacement = \"$1:$2\"\n\t\t}\n\t}\n\n\tdiscovery.relabel
\"kubernetes_pods_mutex_custom_name\" {\n\t\ttargets = concat(discovery.relabel.kubernetes_pods.output)\n\n\t\trule
{\n\t\t\tsource_labels = [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_mutex_scrape\"]\n\t\t\taction
\ = \"keep\"\n\t\t\tregex = \"true\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_mutex_port_name\"]\n\t\t\taction
\ = \"drop\"\n\t\t\tregex = \"\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_container_port_name\"]\n\t\t\ttarget_label = \"__meta_kubernetes_pod_annotation_profiles_grafana_com_mutex_port_name\"\n\t\t\taction
\ = \"keepequal\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels = [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_mutex_scheme\"]\n\t\t\taction
\ = \"replace\"\n\t\t\tregex = \"(https?)\"\n\t\t\ttarget_label
\ = \"__scheme__\"\n\t\t\treplacement = \"$1\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_mutex_path\"]\n\t\t\taction
\ = \"replace\"\n\t\t\tregex = \"(.+)\"\n\t\t\ttarget_label = \"__profile_path__\"\n\t\t\treplacement
\ = \"$1\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels = [\"__address__\", \"__meta_kubernetes_pod_annotation_profiles_grafana_com_mutex_port\"]\n\t\t\taction
\ = \"replace\"\n\t\t\tregex = \"(.+?)(?::\\\\d+)?;(\\\\d+)\"\n\t\t\ttarget_label
\ = \"__address__\"\n\t\t\treplacement = \"$1:$2\"\n\t\t}\n\t}\n\n\t/*****************************************************************\n\t*
Kubernetes Pyroscope Scrape Mutex\n\t*****************************************************************/\n\tpyroscope.scrape
\"pyroscope_scrape_mutex\" {\n\t\tclustering {\n\t\t\tenabled = true\n\t\t}\n\n\t\ttargets
\ = concat(discovery.relabel.kubernetes_pods_mutex_default_name.output, discovery.relabel.kubernetes_pods_mutex_custom_name.output)\n\t\tforward_to
= argument.forward_to.value\n\n\t\tprofiling_config {\n\t\t\tprofile.memory {\n\t\t\t\tenabled
= false\n\t\t\t}\n\n\t\t\tprofile.process_cpu {\n\t\t\t\tenabled = false\n\t\t\t}\n\n\t\t\tprofile.goroutine
{\n\t\t\t\tenabled = false\n\t\t\t}\n\n\t\t\tprofile.block {\n\t\t\t\tenabled
= false\n\t\t\t}\n\n\t\t\tprofile.mutex {\n\t\t\t\tenabled = true\n\t\t\t}\n\n\t\t\tprofile.fgprof
{\n\t\t\t\tenabled = false\n\t\t\t}\n\t\t}\n\t}\n\n\tdiscovery.relabel \"kubernetes_pods_fgprof_default_name\"
{\n\t\ttargets = concat(discovery.relabel.kubernetes_pods.output)\n\n\t\trule
{\n\t\t\tsource_labels = [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_fgprof_scrape\"]\n\t\t\taction
\ = \"keep\"\n\t\t\tregex = \"true\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_fgprof_port_name\"]\n\t\t\taction
\ = \"keep\"\n\t\t\tregex = \"\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_fgprof_scheme\"]\n\t\t\taction
\ = \"replace\"\n\t\t\tregex = \"(https?)\"\n\t\t\ttarget_label
\ = \"__scheme__\"\n\t\t\treplacement = \"$1\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_fgprof_path\"]\n\t\t\taction
\ = \"replace\"\n\t\t\tregex = \"(.+)\"\n\t\t\ttarget_label = \"__profile_path__\"\n\t\t\treplacement
\ = \"$1\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels = [\"__address__\", \"__meta_kubernetes_pod_annotation_profiles_grafana_com_fgprof_port\"]\n\t\t\taction
\ = \"replace\"\n\t\t\tregex = \"(.+?)(?::\\\\d+)?;(\\\\d+)\"\n\t\t\ttarget_label
\ = \"__address__\"\n\t\t\treplacement = \"$1:$2\"\n\t\t}\n\t}\n\n\tdiscovery.relabel
\"kubernetes_pods_fgprof_custom_name\" {\n\t\ttargets = concat(discovery.relabel.kubernetes_pods.output)\n\n\t\trule
{\n\t\t\tsource_labels = [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_fgprof_scrape\"]\n\t\t\taction
\ = \"keep\"\n\t\t\tregex = \"true\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_fgprof_port_name\"]\n\t\t\taction
\ = \"drop\"\n\t\t\tregex = \"\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_container_port_name\"]\n\t\t\ttarget_label = \"__meta_kubernetes_pod_annotation_profiles_grafana_com_fgprof_port_name\"\n\t\t\taction
\ = \"keepequal\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels = [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_fgprof_scheme\"]\n\t\t\taction
\ = \"replace\"\n\t\t\tregex = \"(https?)\"\n\t\t\ttarget_label
\ = \"__scheme__\"\n\t\t\treplacement = \"$1\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels
= [\"__meta_kubernetes_pod_annotation_profiles_grafana_com_fgprof_path\"]\n\t\t\taction
\ = \"replace\"\n\t\t\tregex = \"(.+)\"\n\t\t\ttarget_label = \"__profile_path__\"\n\t\t\treplacement
\ = \"$1\"\n\t\t}\n\n\t\trule {\n\t\t\tsource_labels = [\"__address__\", \"__meta_kubernetes_pod_annotation_profiles_grafana_com_fgprof_port\"]\n\t\t\taction
\ = \"replace\"\n\t\t\tregex = \"(.+?)(?::\\\\d+)?;(\\\\d+)\"\n\t\t\ttarget_label
\ = \"__address__\"\n\t\t\treplacement = \"$1:$2\"\n\t\t}\n\t}\n\n\t/*****************************************************************\n\t*
Kubernetes Pyroscope Scrape Fgprof\n\t*****************************************************************/\n\tpyroscope.scrape
\"pyroscope_scrape_fgprof\" {\n\t\tclustering {\n\t\t\tenabled = true\n\t\t}\n\n\t\ttargets
\ = concat(discovery.relabel.kubernetes_pods_fgprof_default_name.output, discovery.relabel.kubernetes_pods_fgprof_custom_name.output)\n\t\tforward_to
= argument.forward_to.value\n\n\t\tprofiling_config {\n\t\t\tprofile.memory {\n\t\t\t\tenabled
= false\n\t\t\t}\n\n\t\t\tprofile.process_cpu {\n\t\t\t\tenabled = false\n\t\t\t}\n\n\t\t\tprofile.goroutine
{\n\t\t\t\tenabled = false\n\t\t\t}\n\n\t\t\tprofile.block {\n\t\t\t\tenabled
= false\n\t\t\t}\n\n\t\t\tprofile.mutex {\n\t\t\t\tenabled = false\n\t\t\t}\n\n\t\t\tprofile.fgprof
{\n\t\t\t\tenabled = true\n\t\t\t}\n\t\t}\n\t}\n}\n"
kind: ConfigMap
metadata:
name: alloy-modules-kubernetes-profiles-66c27bc84g
namespace: monitoring-system
---
apiVersion: v1
data:
process-and-transform.alloy: "/*\nModule Components: process_and_transform\n\nDescription:
Traces data collection processing and transformation\n*/\n\n// Processing And
Transformation\ndeclare \"process_and_transform\" {\n\n\t/*****************************************************************\n\t*
ARGUMENTS\n\t*****************************************************************/\n\targument
\"traces_forward_to\" {\n\t\tcomment = \"Must be a list(TracesReceiver) where
collected traces should be forwarded to\"\n\t}\n\n\targument \"logs_forward_to\"
{\n\t\tcomment = \"Must be a list(LogsReceiver) where collected logs should be
forwarded to\"\n\t}\n\n\targument \"metrics_forward_to\" {\n\t\tcomment = \"Must
be a list(MetricsReceiver) where collected metrics should be forwarded to\"\n\t}\n\n\targument
\"cluster\" {\n\t\toptional = true\n\t\tdefault = \"k3d-k3s-codelab\"\n\t}\n\n\targument
\"otlp_http_endpoint\" {\n\t\toptional = true\n\t\tdefault = \"0.0.0.0:4318\"\n\t}\n\n\targument
\"otlp_grpc_endpoint\" {\n\t\toptional = true\n\t\tdefault = \"0.0.0.0:4317\"\n\t}\n\n\t/*****************************************************************\n\t*
Jaeger for Metrics Logs Traces\n\t*****************************************************************/\n\totelcol.receiver.jaeger
\"default\" {\n\t\tprotocols {\n\t\t\tgrpc {\n\t\t\t\tendpoint = \"0.0.0.0:14250\"\n\t\t\t}\n\n\t\t\tthrift_http
{\n\t\t\t\tendpoint = \"0.0.0.0:14268\"\n\t\t\t}\n\n\t\t\tthrift_binary {\n\t\t\t\tendpoint
= \"0.0.0.0:6832\"\n\t\t\t}\n\n\t\t\tthrift_compact {\n\t\t\t\tendpoint = \"0.0.0.0:6831\"\n\t\t\t}\n\t\t}\n\n\t\toutput
{\n\t\t\tmetrics = [otelcol.processor.batch.default.input]\n\t\t\tlogs = [otelcol.processor.resourcedetection.default.input]\n\t\t\ttraces
\ = [otelcol.processor.resourcedetection.default.input]\n\t\t}\n\t}\n\n\t/*****************************************************************\n\t*
Otelcol for Metrics Logs Traces\n\t*****************************************************************/\n\totelcol.receiver.otlp
\"default\" {\n\t\tgrpc {\n\t\t\tendpoint = argument.otlp_grpc_endpoint.value\n\t\t}\n\n\t\thttp
{\n\t\t\tendpoint = argument.otlp_http_endpoint.value\n\t\t}\n\n\t\toutput {\n\t\t\tmetrics
= [otelcol.processor.batch.default.input]\n\t\t\tlogs = [otelcol.processor.resourcedetection.default.input]\n\t\t\ttraces
\ = [\n\t\t\t\totelcol.processor.resourcedetection.default.input,\n\t\t\t\totelcol.connector.spanlogs.autologging.input,\n\t\t\t]\n\t\t}\n\t}\n\n\totelcol.processor.resourcedetection
\"default\" {\n\t\tdetectors = [\"env\"]\n\n\t\toutput {\n\t\t\tlogs = [otelcol.processor.k8sattributes.default.input]\n\t\t\ttraces
= [otelcol.processor.k8sattributes.default.input]\n\t\t}\n\t}\n\n\totelcol.processor.k8sattributes
\"default\" {\n\t\textract {\n\t\t\tmetadata = [\n\t\t\t\t\"k8s.namespace.name\",\n\t\t\t\t\"k8s.pod.name\",\n\t\t\t\t\"k8s.deployment.name\",\n\t\t\t\t\"k8s.statefulset.name\",\n\t\t\t\t\"k8s.daemonset.name\",\n\t\t\t\t\"k8s.cronjob.name\",\n\t\t\t\t\"k8s.job.name\",\n\t\t\t\t\"k8s.node.name\",\n\t\t\t\t\"k8s.pod.uid\",\n\t\t\t\t\"k8s.pod.start_time\",\n\t\t\t]\n\t\t}\n\n\t\tpod_association
{\n\t\t\tsource {\n\t\t\t\tfrom = \"connection\"\n\t\t\t}\n\t\t}\n\n\t\toutput
{\n\t\t\tlogs = [otelcol.processor.transform.add_resource_attributes.input]\n\t\t\ttraces
= [otelcol.processor.transform.add_resource_attributes.input]\n\t\t}\n\t}\n\n\totelcol.processor.transform
\"add_resource_attributes\" {\n\t\terror_mode = \"ignore\"\n\n\t\tlog_statements
{\n\t\t\tcontext = \"resource\"\n\t\t\tstatements = [\n\t\t\t\t`set(attributes[\"pod\"],
attributes[\"k8s.pod.name\"])`,\n\t\t\t\t`set(attributes[\"namespace\"], attributes[\"k8s.namespace.name\"])`,\n\t\t\t\t`set(attributes[\"loki.resource.labels\"],
\"pod, namespace, cluster, job\")`,\n\t\t\t\t`set(attributes[\"k8s.cluster.name\"],
\"k3d-k3s-codelab\") where attributes[\"k8s.cluster.name\"] == nil`,\n\t\t\t]\n\t\t}\n\n\t\ttrace_statements
{\n\t\t\tcontext = \"resource\"\n\t\t\tstatements = [\n\t\t\t\t`set(attributes[\"k8s.cluster.name\"],
\"k3d-k3s-codelab\") where attributes[\"k8s.cluster.name\"] == nil`,\n\t\t\t]\n\t\t}\n\n\t\toutput
{\n\t\t\tlogs = [otelcol.processor.filter.default.input]\n\t\t\ttraces = [otelcol.processor.filter.default.input]\n\t\t}\n\t}\n\n\totelcol.processor.filter
\"default\" {\n\t\terror_mode = \"ignore\"\n\n\t\toutput {\n\t\t\tlogs = [otelcol.processor.batch.default.input]\n\t\t\ttraces
= [otelcol.processor.batch.default.input]\n\t\t}\n\t}\n\n\totelcol.processor.batch
\"default\" {\n\t\tsend_batch_size = 16384\n\t\tsend_batch_max_size = 0\n\t\ttimeout
\ = \"5s\"\n\n\t\toutput {\n\t\t\tmetrics = [otelcol.processor.memory_limiter.default.input]\n\t\t\tlogs
\ = [otelcol.processor.memory_limiter.default.input]\n\t\t\ttraces = [otelcol.processor.memory_limiter.default.input]\n\t\t}\n\t}\n\n\totelcol.processor.memory_limiter
\"default\" {\n\t\tcheck_interval = \"1s\"\n\t\tlimit_percentage =
50\n\t\tspike_limit_percentage = 30\n\n\t\toutput {\n\t\t\tmetrics = [otelcol.exporter.prometheus.tracesmetrics.input]\n\t\t\tlogs
\ = [otelcol.exporter.loki.traceslogs.input]\n\t\t\ttraces = argument.traces_forward_to.value\n\t\t}\n\t}\n\n\totelcol.exporter.prometheus
\"tracesmetrics\" {\n\t\tforward_to = argument.metrics_forward_to.value\n\t}\n\n\totelcol.exporter.loki
\"traceslogs\" {\n\t\tforward_to = [loki.process.traceslogs.receiver]\n\t}\n\n\t//
The OpenTelemetry spanlog connector processes incoming trace spans and extracts
data from them ready\n\t// for logging.\n\totelcol.connector.spanlogs \"autologging\"
{\n\t\t// We only want to output a line for each root span (ie. every single trace),
and not for every\n\t\t// process or span (outputting a line for every span would
be extremely verbose).\n\t\tspans = false\n\t\troots = true\n\t\tprocesses
= false\n\n\t\t// We want to ensure that the following three span attributes are
included in the log line, if present.\n\t\tspan_attributes = [\n\t\t\t\"http.method\",\n\t\t\t\"http.target\",\n\t\t\t\"http.status_code\",\n\t\t]\n\n\t\t//
Overrides the default key in the log line to be `traceId`, which is then used
by Grafana to\n\t\t// identify the trace ID for correlation with the Tempo datasource.\n\t\toverrides
{\n\t\t\ttrace_id_key = \"traceId\"\n\t\t}\n\n\t\t// Send to the OpenTelemetry
Loki exporter.\n\t\toutput {\n\t\t\tlogs = [otelcol.exporter.loki.autologging.input]\n\t\t}\n\t}\n\n\t//
Simply forwards the incoming OpenTelemetry log format out as a Loki log.\n\t//
We need this stage to ensure we can then process the logline as a Loki object.\n\totelcol.exporter.loki
\"autologging\" {\n\t\tforward_to = [loki.process.autologging.receiver]\n\t}\n\n\t//
The Loki processor allows us to accept a correctly formatted Loki log and mutate
it into\n\t// a set of fields for output.\n\tloki.process \"autologging\" {\n\t\t//
The JSON stage simply extracts the `body` (the actual logline) from the Loki log,
ignoring\n\t\t// all other fields.\n\t\tstage.json {\n\t\t\texpressions = {\"body\"
= \"\"}\n\t\t}\n\t\t// The output stage takes the body (the main logline) and
uses this as the source for the output\n\t\t// logline. In this case, it essentially
turns it into logfmt.\n\t\tstage.output {\n\t\t\tsource = \"body\"\n\t\t}\n\n\t\tforward_to
= [loki.process.traceslogs.receiver]\n\t}\n\n\tloki.process \"traceslogs\" {\n\t\tstage.tenant
{\n\t\t\tvalue = \"anonymous\"\n\t\t}\n\n\t\tforward_to = argument.logs_forward_to.value\n\t}\n\n\t/*****************************************************************\n\t*
EXPORTS\n\t*****************************************************************/\n\texport
\"alloy_traces_input\" {\n\t\tvalue = otelcol.processor.batch.default.input\n\t}\n}\n"
kind: ConfigMap
metadata:
name: alloy-modules-kubernetes-traces-8mgm8th9m5
namespace: monitoring-system
---
apiVersion: v1
data:
alertmanager_fallback_config.yaml: |
route:
group_wait: 0s
receiver: empty-receiver
receivers:
# In this example we're not going to send any notification out of Alertmanager.
- name: 'empty-receiver'
mimir.yaml: |
# Do not use this configuration in production.
# It is for demonstration purposes only.
multitenancy_enabled: false
# -usage-stats.enabled=false
usage_stats:
enabled: false
server:
http_listen_port: 8080
grpc_listen_port: 9095
log_level: info
# https://grafana.com/docs/mimir/latest/references/configuration-parameters/#use-environment-variables-in-the-configuration
common:
storage:
backend: s3
s3:
endpoint: ${MIMIR_S3_ENDPOINT:minio.minio-system.svc:443}
access_key_id: ${MIMIR_S3_ACCESS_KEY_ID:lgtmp}
secret_access_key: ${MIMIR_S3_SECRET_ACCESS_KEY:supersecret}
insecure: ${MIMIR_S3_INSECURE:false}
http:
insecure_skip_verify: true
alertmanager:
data_dir: /data/alertmanager
enable_api: true
external_url: /alertmanager
fallback_config_file: /etc/mimir/alertmanager_fallback_config.yaml
alertmanager_storage:
s3:
bucket_name: mimir-alertmanager
memberlist:
join_members: [ mimir-memberlist:7946 ]
ingester:
ring:
replication_factor: 1
store_gateway:
sharding_ring:
replication_factor: 1
blocks_storage:
s3:
bucket_name: mimir-blocks
tsdb:
dir: /data/ingester
ship_interval: 1m
block_ranges_period: [ 2h ]
retention_period: 3h
bucket_store:
index_cache:
backend: memcached
memcached:
addresses: dns+memcached.memcached-system.svc:11211
chunks_cache:
backend: memcached
memcached:
addresses: dns+memcached.memcached-system.svc:11211
metadata_cache: