mirror of
https://github.com/dominikhoebert/docker-projects.git
synced 2025-07-21 20:47:05 +00:00
229 lines
5.1 KiB
Plaintext
229 lines
5.1 KiB
Plaintext
/* Grafana Alloy Configuration Examples
|
|
* ---
|
|
* LINK: For more details, visit https://github.com/grafana/alloy-scenarios
|
|
*/
|
|
|
|
// SECTION: TARGETS
|
|
|
|
loki.write "default" {
|
|
endpoint {
|
|
url = "http://loki:3100/loki/api/v1/push"
|
|
}
|
|
external_labels = {}
|
|
}
|
|
|
|
prometheus.remote_write "default" {
|
|
endpoint {
|
|
url = "http://prometheus:9090/api/v1/write"
|
|
}
|
|
}
|
|
|
|
// !SECTION
|
|
|
|
// SECTION: SYSTEM LOGS & JOURNAL
|
|
|
|
|
|
local.file_match "system" {
|
|
path_targets = [{
|
|
__address__ = "localhost",
|
|
__path__ = "/var/log/{syslog,messages,*.log}",
|
|
instance = constants.hostname,
|
|
job = string.format("%s-logs", constants.hostname),
|
|
}]
|
|
}
|
|
|
|
discovery.relabel "journal" {
|
|
targets = []
|
|
rule {
|
|
source_labels = ["__journal__systemd_unit"]
|
|
target_label = "unit"
|
|
}
|
|
rule {
|
|
source_labels = ["__journal__boot_id"]
|
|
target_label = "boot_id"
|
|
}
|
|
rule {
|
|
source_labels = ["__journal__transport"]
|
|
target_label = "transport"
|
|
}
|
|
rule {
|
|
source_labels = ["__journal_priority_keyword"]
|
|
target_label = "level"
|
|
}
|
|
}
|
|
|
|
loki.source.file "system" {
|
|
targets = local.file_match.system.targets
|
|
forward_to = [loki.write.default.receiver]
|
|
}
|
|
|
|
// !SECTION
|
|
|
|
// SECTION: SYSTEM METRICS
|
|
|
|
discovery.relabel "metrics" {
|
|
targets = prometheus.exporter.unix.metrics.targets
|
|
rule {
|
|
target_label = "instance"
|
|
replacement = constants.hostname
|
|
}
|
|
rule {
|
|
target_label = "job"
|
|
replacement = string.format("%s-metrics", constants.hostname)
|
|
}
|
|
}
|
|
|
|
prometheus.exporter.unix "metrics" {
|
|
disable_collectors = ["ipvs", "btrfs", "infiniband", "xfs", "zfs"]
|
|
enable_collectors = ["meminfo"]
|
|
filesystem {
|
|
fs_types_exclude = "^(autofs|binfmt_misc|bpf|cgroup2?|configfs|debugfs|devpts|devtmpfs|tmpfs|fusectl|hugetlbfs|iso9660|mqueue|nsfs|overlay|proc|procfs|pstore|rpc_pipefs|securityfs|selinuxfs|squashfs|sysfs|tracefs)$"
|
|
mount_points_exclude = "^/(dev|proc|run/credentials/.+|sys|var/lib/docker/.+)($|/)"
|
|
mount_timeout = "5s"
|
|
}
|
|
netclass {
|
|
ignored_devices = "^(veth.*|cali.*|[a-f0-9]{15})$"
|
|
}
|
|
netdev {
|
|
device_exclude = "^(veth.*|cali.*|[a-f0-9]{15})$"
|
|
}
|
|
}
|
|
|
|
prometheus.scrape "metrics" {
|
|
scrape_interval = "15s"
|
|
targets = discovery.relabel.metrics.output
|
|
forward_to = [prometheus.remote_write.default.receiver]
|
|
}
|
|
|
|
// !SECTION
|
|
|
|
// SECTION: DOCKER METRICS
|
|
|
|
prometheus.exporter.cadvisor "dockermetrics" {
|
|
docker_host = "unix:///var/run/docker.sock"
|
|
storage_duration = "5m"
|
|
}
|
|
|
|
prometheus.scrape "dockermetrics" {
|
|
targets = prometheus.exporter.cadvisor.dockermetrics.targets
|
|
forward_to = [ prometheus.remote_write.default.receiver ]
|
|
scrape_interval = "10s"
|
|
}
|
|
|
|
//!SECTION
|
|
|
|
// SECTION: DOCKER LOGS
|
|
|
|
discovery.docker "dockerlogs" {
|
|
host = "unix:///var/run/docker.sock"
|
|
}
|
|
|
|
discovery.relabel "dockerlogs" {
|
|
targets = []
|
|
|
|
rule {
|
|
source_labels = ["__meta_docker_container_name"]
|
|
regex = "/(.*)"
|
|
target_label = "service_name"
|
|
}
|
|
|
|
}
|
|
|
|
loki.source.docker "default" {
|
|
host = "unix:///var/run/docker.sock"
|
|
targets = discovery.docker.dockerlogs.targets
|
|
labels = {"platform" = "docker"}
|
|
relabel_rules = discovery.relabel.dockerlogs.rules
|
|
forward_to = [loki.write.default.receiver]
|
|
}
|
|
|
|
// !SECTION
|
|
|
|
// ####################################
|
|
// Windows Server Metrics Configuration
|
|
// ####################################
|
|
|
|
prometheus.exporter.windows "default" {
|
|
enabled_collectors = ["cpu","cs","logical_disk","net","os","service","system", "memory", "scheduled_task", "tcp"]
|
|
}
|
|
|
|
// Configure a prometheus.scrape component to collect windows metrics.
|
|
prometheus.scrape "example" {
|
|
targets = prometheus.exporter.windows.default.targets
|
|
forward_to = [prometheus.remote_write.demo.receiver]
|
|
}
|
|
|
|
prometheus.remote_write "demo" {
|
|
endpoint {
|
|
url = "http://prometheus:9090/api/v1/write"
|
|
}
|
|
}
|
|
|
|
// ####################################
|
|
// Windows Server Logs Configuration
|
|
// ####################################
|
|
|
|
loki.source.windowsevent "application" {
|
|
eventlog_name = "Application"
|
|
use_incoming_timestamp = true
|
|
forward_to = [loki.process.endpoint.receiver]
|
|
}
|
|
|
|
loki.source.windowsevent "System" {
|
|
eventlog_name = "System"
|
|
use_incoming_timestamp = true
|
|
forward_to = [loki.process.endpoint.receiver]
|
|
}
|
|
|
|
loki.process "endpoint" {
|
|
forward_to = [loki.write.endpoint.receiver]
|
|
stage.json {
|
|
expressions = {
|
|
message = "",
|
|
Overwritten = "",
|
|
source = "",
|
|
computer = "",
|
|
eventRecordID = "",
|
|
channel = "",
|
|
component_id = "",
|
|
execution_processId = "",
|
|
execution_processName = "",
|
|
}
|
|
}
|
|
|
|
stage.structured_metadata {
|
|
values = {
|
|
"eventRecordID" = "",
|
|
"channel" = "",
|
|
"component_id" = "",
|
|
"execution_processId" = "",
|
|
"execution_processName" = "",
|
|
}
|
|
}
|
|
|
|
stage.eventlogmessage {
|
|
source = "message"
|
|
overwrite_existing = true
|
|
}
|
|
|
|
stage.labels {
|
|
values = {
|
|
"service_name" = "source",
|
|
}
|
|
}
|
|
|
|
stage.output {
|
|
source = "message"
|
|
}
|
|
|
|
}
|
|
|
|
|
|
loki.write "endpoint" {
|
|
endpoint {
|
|
url ="http://loki:3100/loki/api/v1/push"
|
|
}
|
|
}
|
|
|
|
livedebugging{}
|