diff --git a/go.mod b/go.mod index 4b18ed39a1..cf8c2987e5 100644 --- a/go.mod +++ b/go.mod @@ -6,32 +6,32 @@ replace github.com/influxdata/telegraf => github.com/aws/telegraf v0.10.2-0.2022 // Replace with https://github.com/amazon-contributing/opentelemetry-collector-contrib, there are no requirements for all receivers/processors/exporters // to be all replaced since there are some changes that will always be from upstream -replace github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsemfexporter => github.com/amazon-contributing/opentelemetry-collector-contrib/exporter/awsemfexporter v0.0.0-20230825162106-dc5e1490a681 +replace github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsemfexporter => github.com/amazon-contributing/opentelemetry-collector-contrib/exporter/awsemfexporter v0.0.0-20230905153800-7f3842989e5b -replace github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsxrayexporter => github.com/amazon-contributing/opentelemetry-collector-contrib/exporter/awsxrayexporter v0.0.0-20230825162106-dc5e1490a681 +replace github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsxrayexporter => github.com/amazon-contributing/opentelemetry-collector-contrib/exporter/awsxrayexporter v0.0.0-20230905153800-7f3842989e5b -replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/xray => github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/xray v0.0.0-20230825162106-dc5e1490a681 +replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/xray => github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/xray v0.0.0-20230905153800-7f3842989e5b -replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscontainerinsightreceiver => github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/awscontainerinsightreceiver v0.0.0-20230825162106-dc5e1490a681 +replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscontainerinsightreceiver => github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/awscontainerinsightreceiver v0.0.0-20230905153800-7f3842989e5b -replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/k8s => github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/k8s v0.0.0-20230825162106-dc5e1490a681 +replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/k8s => github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/k8s v0.0.0-20230905153800-7f3842989e5b -replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/containerinsight => github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/containerinsight v0.0.0-20230825162106-dc5e1490a681 +replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/containerinsight => github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/containerinsight v0.0.0-20230905153800-7f3842989e5b // Replace with contrib to revert upstream change https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/20519 -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheus => github.com/amazon-contributing/opentelemetry-collector-contrib/pkg/translator/prometheus v0.0.0-20230825162106-dc5e1490a681 +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheus => github.com/amazon-contributing/opentelemetry-collector-contrib/pkg/translator/prometheus v0.0.0-20230905153800-7f3842989e5b -replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver => github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/prometheusreceiver v0.0.0-20230825162106-dc5e1490a681 +replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver => github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/prometheusreceiver v0.0.0-20230905153800-7f3842989e5b -replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/awsutil => github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/awsutil v0.0.0-20230825162106-dc5e1490a681 +replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/awsutil => github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/awsutil v0.0.0-20230905153800-7f3842989e5b -replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/cwlogs => github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/cwlogs v0.0.0-20230825162106-dc5e1490a681 +replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/cwlogs => github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/cwlogs v0.0.0-20230905153800-7f3842989e5b -replace github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awscloudwatchlogsexporter => github.com/amazon-contributing/opentelemetry-collector-contrib/exporter/awscloudwatchlogsexporter v0.0.0-20230825162106-dc5e1490a681 +replace github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awscloudwatchlogsexporter => github.com/amazon-contributing/opentelemetry-collector-contrib/exporter/awscloudwatchlogsexporter v0.0.0-20230905153800-7f3842989e5b -replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awsxrayreceiver => github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/awsxrayreceiver v0.0.0-20230825162106-dc5e1490a681 +replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awsxrayreceiver => github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/awsxrayreceiver v0.0.0-20230905153800-7f3842989e5b -replace github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws => github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230825162106-dc5e1490a681 +replace github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws => github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230905153800-7f3842989e5b // Temporary fix, pending PR https://github.com/shirou/gopsutil/pull/957 replace github.com/shirou/gopsutil/v3 => github.com/aws/telegraf/patches/gopsutil/v3 v3.0.0-20220502160831-c20ebe67c5ef // indirect diff --git a/go.sum b/go.sum index 9dc652ae40..1aa07267e2 100644 --- a/go.sum +++ b/go.sum @@ -143,32 +143,32 @@ github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk5 github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 h1:s6gZFSlWYmbqAuRjVTiNNhvNRfY2Wxp9nhfyel4rklc= github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE= github.com/aliyun/alibaba-cloud-sdk-go v1.61.1483 h1:J8HaD+Zpfi1gcel3HCKpoHHEsrcuRrZlSnx7R9SCf5I= -github.com/amazon-contributing/opentelemetry-collector-contrib/exporter/awscloudwatchlogsexporter v0.0.0-20230825162106-dc5e1490a681 h1:/9GhYlUU468BnX6ovdf3UAa+PCfWu/IUlhjNViJyYzk= -github.com/amazon-contributing/opentelemetry-collector-contrib/exporter/awscloudwatchlogsexporter v0.0.0-20230825162106-dc5e1490a681/go.mod h1:bgkxykIgZsmF2+TZLuON8KiMEXNSUIASpWC91OhooUc= -github.com/amazon-contributing/opentelemetry-collector-contrib/exporter/awsemfexporter v0.0.0-20230825162106-dc5e1490a681 h1:IINOAS4+mYYyMIBfZPW3v5j4hvghRM+AVwXp6uqgqKc= -github.com/amazon-contributing/opentelemetry-collector-contrib/exporter/awsemfexporter v0.0.0-20230825162106-dc5e1490a681/go.mod h1:vTq1y0k4nw64gsMckp1j1Mb1yRYtbEXcI11JXALnZe0= -github.com/amazon-contributing/opentelemetry-collector-contrib/exporter/awsxrayexporter v0.0.0-20230825162106-dc5e1490a681 h1:LXCxsDx1YI3yn8QBArCdaOXQFK0DPvKLhjlgDJiSiHc= -github.com/amazon-contributing/opentelemetry-collector-contrib/exporter/awsxrayexporter v0.0.0-20230825162106-dc5e1490a681/go.mod h1:WlYOrOBltYFxwGaWbQeLOylFlfBHVvmZDqxc2QCkTXI= -github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/awsutil v0.0.0-20230825162106-dc5e1490a681 h1:DCoM/VwECOKN0MSlyCm8JqVO4gMBRH8Evt6B9hxn+Y8= -github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/awsutil v0.0.0-20230825162106-dc5e1490a681/go.mod h1:rR33E1WOYPfFhIjNONBJpbqTzDTi45N1oAHiqd0Q19E= -github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/containerinsight v0.0.0-20230825162106-dc5e1490a681 h1:WBkUZvAMIoptl40QT1vrrjS+89RW7GNAnaNpK/7MyjI= -github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/containerinsight v0.0.0-20230825162106-dc5e1490a681/go.mod h1:b9KA+hw/wH0cO3D2bnUp0oTUzDuoDandrl7p2hzgBtQ= -github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/cwlogs v0.0.0-20230825162106-dc5e1490a681 h1:w2k4xdjO4bbOd1haW09/NdnT33XuEi5Ma+YdOOW/Rmc= -github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/cwlogs v0.0.0-20230825162106-dc5e1490a681/go.mod h1:leu6SU6eqJeveXxY+wFdxnLvQua0hORuqTGrRjUHoVI= -github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/k8s v0.0.0-20230825162106-dc5e1490a681 h1:Rm7QULejz0Gp1DWt/YtNcwReW0axOrvpoFPt2sPrq10= -github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/k8s v0.0.0-20230825162106-dc5e1490a681/go.mod h1:Oy2KtD3Rbby6z1OVPY8qyQIDqnQASytn3QpdhvgAPJ8= -github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/xray v0.0.0-20230825162106-dc5e1490a681 h1:Q/FcSMqGrKIdJPbtBGro5Z/kMc/stisp6LdMLPiMQpo= -github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/xray v0.0.0-20230825162106-dc5e1490a681/go.mod h1:6Vwl/+yXrD21CtE1emsNFeaAW0cq5GbY+HlXaILADh4= -github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230825162106-dc5e1490a681 h1:C0E/bo2VN2nk6Mtx/imJctN7RpXaYSr/jjylWpEnLl4= -github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230825162106-dc5e1490a681/go.mod h1:F5l/VuHtB8418NLJEsHeYz/pni6sWtOMR/SM6mgarhQ= -github.com/amazon-contributing/opentelemetry-collector-contrib/pkg/translator/prometheus v0.0.0-20230825162106-dc5e1490a681 h1:4R/36KmIE0i0if/Q9C9eXYcrndEd1x1FlmbgzvxrqAo= -github.com/amazon-contributing/opentelemetry-collector-contrib/pkg/translator/prometheus v0.0.0-20230825162106-dc5e1490a681/go.mod h1:UHT79wwd4bjA5Z7hQ9Cx6vbr5Pr7HK+PNLeOMt15+m8= -github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/awscontainerinsightreceiver v0.0.0-20230825162106-dc5e1490a681 h1:wjpRWwIx45gsDlRiLYVg9zxzZKsdsHC94bSNTJCLmhg= -github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/awscontainerinsightreceiver v0.0.0-20230825162106-dc5e1490a681/go.mod h1:ti3fngqVFdzkSBnjHrcyPJfy+mqNaqTWfMxscmF6Nz4= -github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/awsxrayreceiver v0.0.0-20230825162106-dc5e1490a681 h1:7iYlcEwagD9yci+dczyCsi0U50pXjJwB5sBYH03L/rQ= -github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/awsxrayreceiver v0.0.0-20230825162106-dc5e1490a681/go.mod h1:6Sorrx5WVtD3I89CXf85XPMFN9fSCaWUB0RwydRPa2Y= -github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/prometheusreceiver v0.0.0-20230825162106-dc5e1490a681 h1:3g2F1aWVSwGE1V9amYq69QuEvGHRqi87gXEluzlri/E= -github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/prometheusreceiver v0.0.0-20230825162106-dc5e1490a681/go.mod h1:Hle+DN7pi6FnsogIVsp+9n0k0EHrhYLszIDSWvRn1EY= +github.com/amazon-contributing/opentelemetry-collector-contrib/exporter/awscloudwatchlogsexporter v0.0.0-20230905153800-7f3842989e5b h1:KoVwc4rJPeqAGcE2fswcOYWG7x9cIbFsmf6U9iBDOXU= +github.com/amazon-contributing/opentelemetry-collector-contrib/exporter/awscloudwatchlogsexporter v0.0.0-20230905153800-7f3842989e5b/go.mod h1:bgkxykIgZsmF2+TZLuON8KiMEXNSUIASpWC91OhooUc= +github.com/amazon-contributing/opentelemetry-collector-contrib/exporter/awsemfexporter v0.0.0-20230905153800-7f3842989e5b h1:25FiAtkoly/nmbG4M//3bFgjcxQNE0uKvTNwUruqiPI= +github.com/amazon-contributing/opentelemetry-collector-contrib/exporter/awsemfexporter v0.0.0-20230905153800-7f3842989e5b/go.mod h1:vTq1y0k4nw64gsMckp1j1Mb1yRYtbEXcI11JXALnZe0= +github.com/amazon-contributing/opentelemetry-collector-contrib/exporter/awsxrayexporter v0.0.0-20230905153800-7f3842989e5b h1:Bgs/832drBrppGkorT+lkXMD0C2I2JTkKTYClxI7OYM= +github.com/amazon-contributing/opentelemetry-collector-contrib/exporter/awsxrayexporter v0.0.0-20230905153800-7f3842989e5b/go.mod h1:WlYOrOBltYFxwGaWbQeLOylFlfBHVvmZDqxc2QCkTXI= +github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/awsutil v0.0.0-20230905153800-7f3842989e5b h1:8qQSNpsliV5cIxJ4Ant1PXyp0MT/lpClEF3S2NW5lH0= +github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/awsutil v0.0.0-20230905153800-7f3842989e5b/go.mod h1:rR33E1WOYPfFhIjNONBJpbqTzDTi45N1oAHiqd0Q19E= +github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/containerinsight v0.0.0-20230905153800-7f3842989e5b h1:a1CSJbhzpxZpIQW6r+rp1CkovYG4IkvMKETBqg/hhJw= +github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/containerinsight v0.0.0-20230905153800-7f3842989e5b/go.mod h1:b9KA+hw/wH0cO3D2bnUp0oTUzDuoDandrl7p2hzgBtQ= +github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/cwlogs v0.0.0-20230905153800-7f3842989e5b h1:7YCU5VNM2mglh+J8neYi61yF/+bBxCku5yUFnYXnSaE= +github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/cwlogs v0.0.0-20230905153800-7f3842989e5b/go.mod h1:leu6SU6eqJeveXxY+wFdxnLvQua0hORuqTGrRjUHoVI= +github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/k8s v0.0.0-20230905153800-7f3842989e5b h1:2Fg+a9ZCepkk+MwanPm14j2rWU1icpkAXiolOJJawMo= +github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/k8s v0.0.0-20230905153800-7f3842989e5b/go.mod h1:Oy2KtD3Rbby6z1OVPY8qyQIDqnQASytn3QpdhvgAPJ8= +github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/xray v0.0.0-20230905153800-7f3842989e5b h1:prumeie+NsH+l7EetznhYJxOc3r5OGe1z8FTjyIYshU= +github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/xray v0.0.0-20230905153800-7f3842989e5b/go.mod h1:6Vwl/+yXrD21CtE1emsNFeaAW0cq5GbY+HlXaILADh4= +github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230905153800-7f3842989e5b h1:riIUMyvPso/F790Ma56YooGDs6ccZgDXzfR4w8nh8v0= +github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws v0.0.0-20230905153800-7f3842989e5b/go.mod h1:F5l/VuHtB8418NLJEsHeYz/pni6sWtOMR/SM6mgarhQ= +github.com/amazon-contributing/opentelemetry-collector-contrib/pkg/translator/prometheus v0.0.0-20230905153800-7f3842989e5b h1:xzh5mPhrIUzXm42YFOF9lQoP/3tst/L4gfmRIVdK87w= +github.com/amazon-contributing/opentelemetry-collector-contrib/pkg/translator/prometheus v0.0.0-20230905153800-7f3842989e5b/go.mod h1:UHT79wwd4bjA5Z7hQ9Cx6vbr5Pr7HK+PNLeOMt15+m8= +github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/awscontainerinsightreceiver v0.0.0-20230905153800-7f3842989e5b h1:vn/adTXZLmAc0ZY0HL0jtA/2VQJOIPePftqSqBGh5u4= +github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/awscontainerinsightreceiver v0.0.0-20230905153800-7f3842989e5b/go.mod h1:ti3fngqVFdzkSBnjHrcyPJfy+mqNaqTWfMxscmF6Nz4= +github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/awsxrayreceiver v0.0.0-20230905153800-7f3842989e5b h1:4OsrPxdcQ+O9L1queih75Bd0U+1z1TZpX7otI+ou5zw= +github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/awsxrayreceiver v0.0.0-20230905153800-7f3842989e5b/go.mod h1:6Sorrx5WVtD3I89CXf85XPMFN9fSCaWUB0RwydRPa2Y= +github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/prometheusreceiver v0.0.0-20230905153800-7f3842989e5b h1:pbPbKh+M7Z8IL256R6F1q/QyHU9ykv/j9ZP1UwpzrUU= +github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/prometheusreceiver v0.0.0-20230905153800-7f3842989e5b/go.mod h1:Hle+DN7pi6FnsogIVsp+9n0k0EHrhYLszIDSWvRn1EY= github.com/amir/raidman v0.0.0-20170415203553-1ccc43bfb9c9 h1:FXrPTd8Rdlc94dKccl7KPmdmIbVh/OjelJ8/vgMRzcQ= github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY= github.com/antchfx/jsonquery v1.1.5 h1:1YWrNFYCcIuJPIjFeOP5b6TXbLSUYY8qqxWbuZOB1qE= diff --git a/plugins/inputs/prometheus/metrics_handler.go b/plugins/inputs/prometheus/metrics_handler.go index 488e855049..d515e015bf 100644 --- a/plugins/inputs/prometheus/metrics_handler.go +++ b/plugins/inputs/prometheus/metrics_handler.go @@ -74,19 +74,22 @@ func (mh *metricsHandler) setEmfMetadata(mms []*metricMaterial) { } } - // Prometheus will use the "job" corresponding to the target in prometheus as a log stream + // Historically, for Prometheus pipelines, we use the "job" corresponding to the target in the prometheus config as the log stream name // https://github.com/aws/amazon-cloudwatch-agent/blob/59cfe656152e31ca27e7983fac4682d0c33d3316/plugins/inputs/prometheus_scraper/metrics_handler.go#L80-L84 - // While determining the target, we would give preference to the metric tag over the log_stream_name coming from config/toml as per - // https://github.com/aws/amazon-cloudwatch-agent/blob/60ca11244badf0cb3ae9dd9984c29f41d7a69302/plugins/outputs/cloudwatchlogs/cloudwatchlogs.go#L175-L180. + // As can be seen, if the "job" tag was available, the log_stream_name would be set to it and if it wasnt available for some reason, the log_stream_name would be set as "default". + // The old cloudwatchlogs exporter had logic to look for log_stream_name and if not found, it would use the log_stream_name defined in the config + // https://github.com/aws/amazon-cloudwatch-agent/blob/60ca11244badf0cb3ae9dd9984c29f41d7a69302/plugins/outputs/cloudwatchlogs/cloudwatchlogs.go#L175-L180 + // But as we see above, there should never be a case for Prometheus pipelines where log_stream_name wasnt being set in metrics_handler - so the log_stream_name in the config would have never been used. - // However, since we are using awsemfexport, we can leverage the token replacement with the log stream name + // Now that we have switched to awsemfexporter, we leverage the token replacement logic to dynamically set the log stream name // https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/897db04f747f0bda1707c916b1ec9f6c79a0c678/exporter/awsemfexporter/util.go#L29-L37 - // Therefore, add a tag {ServiceName} for replacing job as a log stream + // Hence we always set the log stream name in the default exporter config as {JobName} during config translation. + // If we have a "job" tag, we do NOT add a tag for "JobName" here since the fallback logic in awsemfexporter while doing pattern matching will fallback from "JobName" -> "job" and use that. + // Only when "job" tag isnt available, we set the "JobName" tag to default to retain same logic as before. + // We do it this way so we dont unnecessarily add an extra tag (that the awsemfexporter wont know to drop) for most cases where "job" will be defined. - if job, ok := mm.tags["job"]; ok { - mm.tags["ServiceName"] = job - } else { - mm.tags["ServiceName"] = "default" + if _, ok := mm.tags["job"]; !ok { + mm.tags["JobName"] = "default" } } } diff --git a/translator/tocwconfig/sampleConfig/prometheus_config_linux.yaml b/translator/tocwconfig/sampleConfig/prometheus_config_linux.yaml index 23baf5718f..b198362cd8 100644 --- a/translator/tocwconfig/sampleConfig/prometheus_config_linux.yaml +++ b/translator/tocwconfig/sampleConfig/prometheus_config_linux.yaml @@ -14,7 +14,7 @@ exporters: local_mode: false log_group_name: /aws/ecs/containerinsights/TestCluster/prometheus log_retention: 0 - log_stream_name: '{ServiceName}' + log_stream_name: '{JobName}' max_retries: 2 metric_descriptors: - metric_name: "nginx_request_count" diff --git a/translator/tocwconfig/sampleConfig/prometheus_config_windows.yaml b/translator/tocwconfig/sampleConfig/prometheus_config_windows.yaml index 6cd63d1a11..463b596cb9 100644 --- a/translator/tocwconfig/sampleConfig/prometheus_config_windows.yaml +++ b/translator/tocwconfig/sampleConfig/prometheus_config_windows.yaml @@ -14,7 +14,7 @@ exporters: local_mode: false log_group_name: /aws/ecs/containerinsights/TestCluster/prometheus log_retention: 0 - log_stream_name: '{ServiceName}' + log_stream_name: '{JobName}' max_retries: 2 metric_descriptors: - metric_name: "nginx_request_count" diff --git a/translator/translate/otel/exporter/awsemf/awsemf_default_prometheus.yaml b/translator/translate/otel/exporter/awsemf/awsemf_default_prometheus.yaml index f6a8091faf..2781008fa7 100644 --- a/translator/translate/otel/exporter/awsemf/awsemf_default_prometheus.yaml +++ b/translator/translate/otel/exporter/awsemf/awsemf_default_prometheus.yaml @@ -1,4 +1,4 @@ -log_stream_name: "{ServiceName}" +log_stream_name: "{JobName}" resource_to_telemetry_conversion: enabled: true detailed_metrics: false diff --git a/translator/translate/otel/exporter/awsemf/translator.go b/translator/translate/otel/exporter/awsemf/translator.go index 95c211bacb..0eee896963 100644 --- a/translator/translate/otel/exporter/awsemf/translator.go +++ b/translator/translate/otel/exporter/awsemf/translator.go @@ -142,13 +142,6 @@ func setPrometheusFields(conf *confmap.Conf, cfg *awsemfexporter.Config) error { return err } - // Prometheus will use the "job" corresponding to the target in prometheus as a log stream - // While determining the target, we would give preference to the metric tag over the log_stream_name coming from config/toml - - // However, since we are using awsemfexport, we can leverage the token replacement with the log stream name - // https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/897db04f747f0bda1707c916b1ec9f6c79a0c678/exporter/awsemfexporter/util.go#L29-L37 - // Therefore, add a tag {ServiceName} for replacing job as a log stream - if conf.IsSet(emfProcessorBasePathKey) { if err := setPrometheusNamespace(conf, cfg); err != nil { return err diff --git a/translator/translate/otel/exporter/awsemf/translator_test.go b/translator/translate/otel/exporter/awsemf/translator_test.go index 1a141e3618..b6243ffb6a 100644 --- a/translator/translate/otel/exporter/awsemf/translator_test.go +++ b/translator/translate/otel/exporter/awsemf/translator_test.go @@ -425,7 +425,7 @@ func TestTranslator(t *testing.T) { "metrics_collected": map[string]interface{}{ "prometheus": map[string]interface{}{ "log_group_name": "/test/log/group", - "log_stream_name": "{ServiceName}", + "log_stream_name": "{LogStreamName}", "emf_processor": map[string]interface{}{ "metric_declaration": []interface{}{ map[string]interface{}{ @@ -446,7 +446,7 @@ func TestTranslator(t *testing.T) { want: map[string]interface{}{ "namespace": "CWAgent/Prometheus", "log_group_name": "/test/log/group", - "log_stream_name": "{ServiceName}", + "log_stream_name": "{JobName}", "dimension_rollup_option": "NoDimensionRollup", "disable_metric_extraction": false, "enhanced_container_insights": false, @@ -483,7 +483,7 @@ func TestTranslator(t *testing.T) { "prometheus": map[string]interface{}{ "disable_metric_extraction": true, "log_group_name": "/test/log/group", - "log_stream_name": "{ServiceName}", + "log_stream_name": "{JobName}", }, }, }, @@ -491,7 +491,7 @@ func TestTranslator(t *testing.T) { want: map[string]interface{}{ "namespace": "", "log_group_name": "/test/log/group", - "log_stream_name": "{ServiceName}", + "log_stream_name": "{JobName}", "dimension_rollup_option": "NoDimensionRollup", "disable_metric_extraction": true, "enhanced_container_insights": false, @@ -515,7 +515,7 @@ func TestTranslator(t *testing.T) { "metrics_collected": map[string]interface{}{ "prometheus": map[string]interface{}{ "log_group_name": "/test/log/group", - "log_stream_name": "{ServiceName}", + "log_stream_name": "{JobName}", "emf_processor": map[string]interface{}{ "metric_unit": map[string]interface{}{ "jvm_gc_collection_seconds_sum": "Milliseconds", @@ -528,7 +528,7 @@ func TestTranslator(t *testing.T) { want: map[string]interface{}{ "namespace": "CWAgent/Prometheus", "log_group_name": "/test/log/group", - "log_stream_name": "{ServiceName}", + "log_stream_name": "{JobName}", "dimension_rollup_option": "NoDimensionRollup", "disable_metric_extraction": false, "enhanced_container_insights": false, @@ -557,7 +557,7 @@ func TestTranslator(t *testing.T) { "metrics_collected": map[string]interface{}{ "prometheus": map[string]interface{}{ "log_group_name": "/test/log/group", - "log_stream_name": "{ServiceName}", + "log_stream_name": "{JobName}", }, }, }, @@ -565,7 +565,7 @@ func TestTranslator(t *testing.T) { want: map[string]interface{}{ "namespace": "", "log_group_name": "/test/log/group", - "log_stream_name": "{ServiceName}", + "log_stream_name": "{JobName}", "dimension_rollup_option": "NoDimensionRollup", "disable_metric_extraction": false, "enhanced_container_insights": false,