From 1bed08a428ac76417f848cd303d312336d741540 Mon Sep 17 00:00:00 2001 From: Mayank Pande Date: Tue, 17 Dec 2024 12:40:58 +0530 Subject: [PATCH] feat: added pattern hash in metric --- containers/container.go | 2 +- containers/metrics.go | 2 +- go.mod | 2 +- go.sum | 6 ++---- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/containers/container.go b/containers/container.go index f239a4bd..eeb046c8 100644 --- a/containers/container.go +++ b/containers/container.go @@ -370,7 +370,7 @@ func (c *Container) Collect(ch chan<- prometheus.Metric) { } } for _, c := range p.parser.GetSensitiveCounters() { - ch <- counter(metrics.SensitiveLogMessages, float64(c.Messages), source, c.Pattern, c.Sample, c.Regex, c.Name) + ch <- counter(metrics.SensitiveLogMessages, float64(c.Messages), source, c.Pattern, c.Sample, c.Regex, c.Name, c.Hash) } } diff --git a/containers/metrics.go b/containers/metrics.go index 1e0c2a07..d9a32489 100644 --- a/containers/metrics.go +++ b/containers/metrics.go @@ -88,7 +88,7 @@ var metrics = struct { NetBytesReceived: metric("container_net_tcp_bytes_received_total", "Total number of bytes received from the peer", "destination", "actual_destination", "src_workload_name", "src_workload_namespace", "src_workload_kind", "destination_workload_name", "destination_workload_namespace", "destination_workload_kind", "actual_destination_workload_name", "actual_destination_workload_namespace", "actual_destination_workload_kind"), LogMessages: metric("container_log_messages_total", "Number of messages grouped by the automatically extracted repeated pattern", "source", "level", "pattern_hash", "sample"), - SensitiveLogMessages: metric("container_sensitive_log_messages_total", "Number of messages that contain sensitive information", "source", "pattern", "sample", "regex", "name"), + SensitiveLogMessages: metric("container_sensitive_log_messages_total", "Number of messages that contain sensitive information", "source", "pattern", "sample", "regex", "name", "pattern_hash"), ApplicationType: metric("container_application_type", "Type of the application running in the container (e.g. memcached, postgres, mysql)", "application_type"), diff --git a/go.mod b/go.mod index f7b5da9b..f05ca6ba 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,6 @@ require ( github.com/hashicorp/golang-lru/v2 v2.0.5 github.com/jpillora/backoff v1.0.0 github.com/mdlayher/taskstats v0.0.0-20230712191918-387b3d561d14 - github.com/nudgebee/logparser v0.0.0-20241211102337-637d710a1162 github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417 github.com/prometheus/client_golang v1.18.0 github.com/prometheus/common v0.46.0 @@ -138,6 +137,7 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect + github.com/nudgebee/logparser v0.0.0-20241217070538-1fe7ca1e772b // indirect github.com/oklog/ulid v1.3.1 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0-rc2.0.20221005185240-3a7f492d3f1b // indirect diff --git a/go.sum b/go.sum index 5cc500a5..ea214a2f 100644 --- a/go.sum +++ b/go.sum @@ -839,12 +839,10 @@ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRW github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= github.com/ncw/swift v1.0.47/go.mod h1:23YIA4yWVnGwv2dQlN4bB7egfYX6YLn0Yo/S6zZO/ZM= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -github.com/nudgebee/logparser v0.0.0-20241210142322-b2bd9d573f94 h1:Cawv/bZ93Oy9pOizk4NpAkSq/pbA6K5HfIK/s2sNs6s= -github.com/nudgebee/logparser v0.0.0-20241210142322-b2bd9d573f94/go.mod h1:ddmUa8en2sToRL+bBvFkuS1AHvA6Msn56v3BpLMbKoc= -github.com/nudgebee/logparser v0.0.0-20241211095040-6f2c19b5d944 h1:xxKNjxg85roYcNLJe0RgOlrdMtNkZNkHv+0dDcHAsIE= -github.com/nudgebee/logparser v0.0.0-20241211095040-6f2c19b5d944/go.mod h1:ddmUa8en2sToRL+bBvFkuS1AHvA6Msn56v3BpLMbKoc= github.com/nudgebee/logparser v0.0.0-20241211102337-637d710a1162 h1:0NAxxCRfdUfZdXhgiy+PPytEXxGJuYsf5IGzx1DcjFU= github.com/nudgebee/logparser v0.0.0-20241211102337-637d710a1162/go.mod h1:ddmUa8en2sToRL+bBvFkuS1AHvA6Msn56v3BpLMbKoc= +github.com/nudgebee/logparser v0.0.0-20241217070538-1fe7ca1e772b h1:5EeDl1YFDFBEPkjXy6f8WKXZIcWFsB75dr0lxTp8Rqc= +github.com/nudgebee/logparser v0.0.0-20241217070538-1fe7ca1e772b/go.mod h1:ddmUa8en2sToRL+bBvFkuS1AHvA6Msn56v3BpLMbKoc= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=