added loki client role
This commit is contained in:
39
roles/docker_loki_client/templates/config.alloy.j2
Normal file
39
roles/docker_loki_client/templates/config.alloy.j2
Normal file
@@ -0,0 +1,39 @@
|
||||
discovery.docker "linux" {
|
||||
host = "unix:///var/run/docker.sock"
|
||||
}
|
||||
|
||||
discovery.relabel "logs_integrations_docker" {
|
||||
targets = []
|
||||
|
||||
rule {
|
||||
source_labels = ["__meta_docker_container_name"]
|
||||
regex = "/(.*)"
|
||||
target_label = "container_name"
|
||||
}
|
||||
|
||||
rule {
|
||||
source_labels = ["__meta_docker_image_name"]
|
||||
regex = "(.*)"
|
||||
target_label = "image_name"
|
||||
}
|
||||
|
||||
rule {
|
||||
source_labels = ["__meta_docker_container_id"]
|
||||
regex = "(.*)"
|
||||
target_label = "container_id"
|
||||
}
|
||||
}
|
||||
|
||||
loki.source.docker "default" {
|
||||
host = "unix:///var/run/docker.sock"
|
||||
targets = discovery.docker.linux.targets
|
||||
labels = {"source" = "docker", host = "{{ docker_loki_client_config.hostname }} "}
|
||||
relabel_rules = discovery.relabel.logs_integrations_docker.rules
|
||||
forward_to = [loki.write.default.receiver]
|
||||
}
|
||||
|
||||
loki.write "default" {
|
||||
endpoint {
|
||||
url = "{{ docker_loki_client_config.loki.address }}/loki/api/v1/push"
|
||||
}
|
||||
}
|
||||
34
roles/docker_loki_client/templates/vector.yaml.j2
Normal file
34
roles/docker_loki_client/templates/vector.yaml.j2
Normal file
@@ -0,0 +1,34 @@
|
||||
sources:
|
||||
journald:
|
||||
type: journald
|
||||
|
||||
transforms:
|
||||
tag_journald:
|
||||
type: remap
|
||||
inputs:
|
||||
- journald
|
||||
source: |
|
||||
.source = "journald"
|
||||
.unit = ._SYSTEMD_UNIT
|
||||
.process = ._COMM
|
||||
.priority = .PRIORITY
|
||||
.host = "{{ docker_loki_client_config.hostname }}"
|
||||
|
||||
sinks:
|
||||
loki:
|
||||
type: loki
|
||||
inputs:
|
||||
- tag_journald
|
||||
endpoint: "{{ docker_loki_client_config.loki.address }}"
|
||||
healthcheck:
|
||||
enabled: false
|
||||
encoding:
|
||||
codec: json
|
||||
labels:
|
||||
{% raw %}
|
||||
host: "{{ .host }}"
|
||||
source: "{{ .source }}"
|
||||
unit: "{{ .unit }}"
|
||||
process: "{{ .process }}"
|
||||
priority: "{{ .priority }}"
|
||||
{% endraw %}
|
||||
Reference in New Issue
Block a user