Skip to content
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

Feat/logs review #21

Merged
merged 5 commits into from
Jul 3, 2024
Merged
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
157 changes: 2 additions & 155 deletions docker/alloy/config.alloy
Original file line number Diff line number Diff line change
@@ -1,157 +1,4 @@
logging {
level = "debug"
level = "info"
format = "logfmt"
}

////////////////////
// LOGS
////////////////////

// CLASSIC LOGS FILES
local.file_match "logs" {
path_targets = [{"__path__" = "/logs/*.log", "exporter" = "LOGFILE"}]
}

loki.source.file "logfiles" {
targets = local.file_match.logs.targets
forward_to = [loki.write.endpoint.receiver]
}

// JSON LOG FILES
local.file_match "jsonlogs" {
path_targets = [{"__path__" = "/logs/*.json", "exporter" = "JSONFILE"}]
}

loki.source.file "jsonlogfiles" {
targets = local.file_match.jsonlogs.targets
forward_to = [loki.process.jsonlogs.receiver]
}

loki.process "jsonlogs" {
forward_to = [loki.write.endpoint.receiver]

// stage.luhn { }

stage.json {
expressions = {
// timestamp = "timestamp",
application = "context.properties.applicationName",
instance = "context.properties.instance",
trace_id = "mdc.trace_id",
}
}

stage.labels {
values = {
application = "application",
instance = "instance",
trace_id = "trace_id",
}
}

/*stage.timestamp {
source = "timestamp"
format = "RFC3339"
fallback_formats = ["UnixMs",]
}*/

/*stage.luhn {
min_length = 13
replacement = "**MASKED**"
}
*/
}

// EXPORTER (LOKI)
loki.write "endpoint" {
endpoint {
url = "http://loki:3100/loki/api/v1/push"
}
}

/////////////////////////
// AGENT OTEL & TRACES
/////////////////////////

// RECEIVER (OTLP)
otelcol.receiver.otlp "default" {
grpc {
endpoint = "0.0.0.0:4317"
}

http {
endpoint = "0.0.0.0:4318"
}

output {
metrics = [otelcol.processor.batch.default.input]
logs = [otelcol.processor.batch.default.input]
traces = [otelcol.processor.tail_sampling.actuator.input]
}
}

//SAMPLING
/*
otelcol.processor.tail_sampling "actuator" {
policy {
name = "filter_http_url"
type = "string_attribute"
string_attribute {
key = "http.url"
values = ["/actuator/health", "/actuator/prometheus"]
enabled_regex_matching = true
invert_match = true
}
}

policy {
name = "filter_url_path"
type = "string_attribute"
string_attribute {
key = "url.path"
values = ["/actuator/health", "/actuator/prometheus"]
enabled_regex_matching = true
invert_match = true
}
}

output {
traces = [otelcol.processor.batch.default.input]
}
}
*/

otelcol.processor.batch "default" {
output {
metrics = [otelcol.exporter.prometheus.default.input]
logs = [otelcol.exporter.loki.default.input]
traces = [otelcol.exporter.otlp.tempo.input]
}
}

// TRACES EXPORTER (OTLP)
otelcol.exporter.otlp "tempo" {
client {
endpoint = "tempo:4317"

tls {
insecure = true
}
}
}

// METRICS EXPORTER (PROMETHEUS)
otelcol.exporter.prometheus "default" {
forward_to = [prometheus.remote_write.default.receiver]
}

prometheus.remote_write "default" {
endpoint {
url = "http://prometheus:9090/api/v1/write"
}
}

// LOGS EXPORTER (LOKI)
otelcol.exporter.loki "default" {
forward_to = [loki.write.endpoint.receiver]
}
}
13 changes: 7 additions & 6 deletions docker/loki/local-config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
auth_enabled: false

limits_config:
max_global_streams_per_user: 10000

server:
http_listen_port: 3100

common:
instance_addr: 127.0.0.1
path_prefix: /loki
storage:
filesystem:
Expand All @@ -20,9 +18,9 @@ common:
schema_config:
configs:
- from: 2020-10-24
store: boltdb-shipper
store: tsdb
object_store: filesystem
schema: v11
schema: v13
index:
prefix: index_
period: 24h
Expand All @@ -41,4 +39,7 @@ ruler:
#
# If you would like to disable reporting, uncomment the following lines:
analytics:
reporting_enabled: false
reporting_enabled: false

limits_config:
max_global_streams_per_user: 10000
Loading
Loading