diff --git a/converter/internal/staticconvert/internal/build/builder.go b/converter/internal/staticconvert/internal/build/builder.go index 6528a533bc8c..0f92fa327363 100644 --- a/converter/internal/staticconvert/internal/build/builder.go +++ b/converter/internal/staticconvert/internal/build/builder.go @@ -175,6 +175,10 @@ func (b *IntegrationsConfigBuilder) appendExporter(commonConfig *int_config.Comm relabelConfigs = append(relabelConfigs, relabelConfig) } + if relabelConfig := b.getJobRelabelConfig(name, commonConfig.RelabelConfigs); relabelConfig != nil { + relabelConfigs = append(relabelConfigs, b.getJobRelabelConfig(name, commonConfig.RelabelConfigs)) + } + scrapeConfig := prom_config.DefaultScrapeConfig scrapeConfig.JobName = b.formatJobName(name, nil) scrapeConfig.RelabelConfigs = append(commonConfig.RelabelConfigs, relabelConfigs...) @@ -309,6 +313,10 @@ func (b *IntegrationsConfigBuilder) appendExporterV2(commonConfig *common_v2.Met relabelConfigs = append(relabelConfigs, relabelConfig) } + if relabelConfig := b.getJobRelabelConfig(name, commonConfig.Autoscrape.RelabelConfigs); relabelConfig != nil { + relabelConfigs = append(relabelConfigs, relabelConfig) + } + commonConfig.ApplyDefaults(b.cfg.Integrations.ConfigV2.Metrics.Autoscrape) scrapeConfig := prom_config.DefaultScrapeConfig scrapeConfig.JobName = b.formatJobName(name, commonConfig.InstanceKey) @@ -394,3 +402,18 @@ func (b *IntegrationsConfigBuilder) appendExporterBlock(args component.Arguments return common.NewDiscoveryExports(fmt.Sprintf("prometheus.exporter.%s.%s.targets", exporterName, compLabel)) } + +func (b *IntegrationsConfigBuilder) getJobRelabelConfig(name string, relabelConfigs []*relabel.Config) *relabel.Config { + // Don't add a job relabel if that label is already targeted + for _, relabelConfig := range relabelConfigs { + if relabelConfig.TargetLabel == "job" { + return nil + } + } + + defaultConfig := relabel.DefaultRelabelConfig + relabelConfig := &defaultConfig + relabelConfig.TargetLabel = "job" + relabelConfig.Replacement = "integrations/" + name + return relabelConfig +} diff --git a/converter/internal/staticconvert/testdata-v2/integrations_v2.river b/converter/internal/staticconvert/testdata-v2/integrations_v2.river index 71df30bf7e4e..5908cd4f0f5b 100644 --- a/converter/internal/staticconvert/testdata-v2/integrations_v2.river +++ b/converter/internal/staticconvert/testdata-v2/integrations_v2.river @@ -34,6 +34,11 @@ discovery.relabel "integrations_azure1" { target_label = "instance" replacement = "azure1" } + + rule { + target_label = "job" + replacement = "integrations/azure" + } } prometheus.scrape "integrations_azure1" { @@ -55,6 +60,11 @@ discovery.relabel "integrations_azure2" { target_label = "instance" replacement = "azure2" } + + rule { + target_label = "job" + replacement = "integrations/azure" + } } prometheus.scrape "integrations_azure2" { @@ -67,8 +77,17 @@ prometheus.exporter.cadvisor "integrations_cadvisor" { store_container_labels = false } +discovery.relabel "integrations_cadvisor" { + targets = prometheus.exporter.cadvisor.integrations_cadvisor.targets + + rule { + target_label = "job" + replacement = "integrations/cadvisor" + } +} + prometheus.scrape "integrations_cadvisor" { - targets = prometheus.exporter.cadvisor.integrations_cadvisor.targets + targets = discovery.relabel.integrations_cadvisor.output forward_to = [prometheus.remote_write.metrics_default.receiver] job_name = "integrations/cadvisor" } @@ -124,16 +143,34 @@ prometheus.exporter.cloudwatch "integrations_cloudwatch_exporter" { decoupled_scraping { } } +discovery.relabel "integrations_cloudwatch" { + targets = prometheus.exporter.cloudwatch.integrations_cloudwatch_exporter.targets + + rule { + target_label = "job" + replacement = "integrations/cloudwatch" + } +} + prometheus.scrape "integrations_cloudwatch" { - targets = prometheus.exporter.cloudwatch.integrations_cloudwatch_exporter.targets + targets = discovery.relabel.integrations_cloudwatch.output forward_to = [prometheus.remote_write.metrics_default.receiver] job_name = "integrations/cloudwatch" } prometheus.exporter.consul "integrations_consul_exporter" { } +discovery.relabel "integrations_consul" { + targets = prometheus.exporter.consul.integrations_consul_exporter.targets + + rule { + target_label = "job" + replacement = "integrations/consul" + } +} + prometheus.scrape "integrations_consul" { - targets = prometheus.exporter.consul.integrations_consul_exporter.targets + targets = discovery.relabel.integrations_consul.output forward_to = [prometheus.remote_write.metrics_default.receiver] job_name = "integrations/consul" } @@ -150,6 +187,11 @@ discovery.relabel "integrations_dnsmasq" { target_label = "instance" replacement = "dnsmasq-a" } + + rule { + target_label = "job" + replacement = "integrations/dnsmasq" + } } prometheus.scrape "integrations_dnsmasq" { @@ -160,8 +202,17 @@ prometheus.scrape "integrations_dnsmasq" { prometheus.exporter.elasticsearch "integrations_elasticsearch_exporter" { } +discovery.relabel "integrations_elasticsearch" { + targets = prometheus.exporter.elasticsearch.integrations_elasticsearch_exporter.targets + + rule { + target_label = "job" + replacement = "integrations/elasticsearch" + } +} + prometheus.scrape "integrations_elasticsearch" { - targets = prometheus.exporter.elasticsearch.integrations_elasticsearch_exporter.targets + targets = discovery.relabel.integrations_elasticsearch.output forward_to = [prometheus.remote_write.metrics_default.receiver] job_name = "integrations/elasticsearch" } @@ -172,8 +223,17 @@ prometheus.exporter.gcp "integrations_gcp_exporter" { extra_filters = ["loadbalancing.googleapis.com:resource.labels.backend_target_name=\"sample-value\""] } +discovery.relabel "integrations_gcp" { + targets = prometheus.exporter.gcp.integrations_gcp_exporter.targets + + rule { + target_label = "job" + replacement = "integrations/gcp" + } +} + prometheus.scrape "integrations_gcp" { - targets = prometheus.exporter.gcp.integrations_gcp_exporter.targets + targets = discovery.relabel.integrations_gcp.output forward_to = [prometheus.remote_write.metrics_default.receiver] job_name = "integrations/gcp" } @@ -183,16 +243,34 @@ prometheus.exporter.github "integrations_github_exporter" { api_token = "ABCDEFGH-1234-ABCD-1234-ABCDEFGHIJKL" } +discovery.relabel "integrations_github" { + targets = prometheus.exporter.github.integrations_github_exporter.targets + + rule { + target_label = "job" + replacement = "integrations/github" + } +} + prometheus.scrape "integrations_github" { - targets = prometheus.exporter.github.integrations_github_exporter.targets + targets = discovery.relabel.integrations_github.output forward_to = [prometheus.remote_write.metrics_default.receiver] job_name = "integrations/github" } prometheus.exporter.kafka "integrations_kafka_exporter" { } +discovery.relabel "integrations_kafka" { + targets = prometheus.exporter.kafka.integrations_kafka_exporter.targets + + rule { + target_label = "job" + replacement = "integrations/kafka" + } +} + prometheus.scrape "integrations_kafka" { - targets = prometheus.exporter.kafka.integrations_kafka_exporter.targets + targets = discovery.relabel.integrations_kafka.output forward_to = [prometheus.remote_write.metrics_default.receiver] job_name = "integrations/kafka" } @@ -209,6 +287,11 @@ discovery.relabel "integrations_memcached" { target_label = "instance" replacement = "memcached-a" } + + rule { + target_label = "job" + replacement = "integrations/memcached" + } } prometheus.scrape "integrations_memcached" { @@ -236,6 +319,11 @@ discovery.relabel "integrations_mongodb" { target_label = "mongodb_cluster" replacement = "prod-cluster" } + + rule { + target_label = "job" + replacement = "integrations/mongodb" + } } prometheus.scrape "integrations_mongodb" { @@ -248,8 +336,17 @@ prometheus.exporter.mssql "integrations_mssql" { connection_string = "sqlserver://:@:" } +discovery.relabel "integrations_mssql" { + targets = prometheus.exporter.mssql.integrations_mssql.targets + + rule { + target_label = "job" + replacement = "integrations/mssql" + } +} + prometheus.scrape "integrations_mssql" { - targets = prometheus.exporter.mssql.integrations_mssql.targets + targets = discovery.relabel.integrations_mssql.output forward_to = [prometheus.remote_write.metrics_default.receiver] job_name = "integrations/mssql" } @@ -266,6 +363,11 @@ discovery.relabel "integrations_mysql" { target_label = "instance" replacement = "server-a" } + + rule { + target_label = "job" + replacement = "integrations/mysql" + } } prometheus.scrape "integrations_mysql" { @@ -293,6 +395,11 @@ discovery.relabel "integrations_node_exporter" { target_label = "__address__" replacement = "localhost:8099" } + + rule { + target_label = "job" + replacement = "integrations/node_exporter" + } } prometheus.scrape "integrations_node_exporter" { @@ -319,8 +426,17 @@ prometheus.exporter.oracledb "integrations_oracledb" { connection_string = "oracle://user:password@localhost:1521/orcl.localnet" } +discovery.relabel "integrations_oracledb" { + targets = prometheus.exporter.oracledb.integrations_oracledb.targets + + rule { + target_label = "job" + replacement = "integrations/oracledb" + } +} + prometheus.scrape "integrations_oracledb" { - targets = prometheus.exporter.oracledb.integrations_oracledb.targets + targets = discovery.relabel.integrations_oracledb.output forward_to = [prometheus.remote_write.metrics_default.receiver] job_name = "integrations/oracledb" } @@ -337,6 +453,11 @@ discovery.relabel "integrations_postgres" { target_label = "instance" replacement = "postgres-a" } + + rule { + target_label = "job" + replacement = "integrations/postgres" + } } prometheus.scrape "integrations_postgres" { @@ -352,8 +473,17 @@ prometheus.exporter.process "integrations_process_exporter" { } } +discovery.relabel "integrations_process" { + targets = prometheus.exporter.process.integrations_process_exporter.targets + + rule { + target_label = "job" + replacement = "integrations/process" + } +} + prometheus.scrape "integrations_process" { - targets = prometheus.exporter.process.integrations_process_exporter.targets + targets = discovery.relabel.integrations_process.output forward_to = [prometheus.remote_write.metrics_default.receiver] job_name = "integrations/process" } @@ -371,6 +501,11 @@ discovery.relabel "integrations_redis" { target_label = "instance" replacement = "redis-2" } + + rule { + target_label = "job" + replacement = "integrations/redis" + } } prometheus.scrape "integrations_redis" { @@ -386,8 +521,17 @@ prometheus.exporter.snowflake "integrations_snowflake" { warehouse = "SNOWFLAKE_WAREHOUSE" } +discovery.relabel "integrations_snowflake" { + targets = prometheus.exporter.snowflake.integrations_snowflake.targets + + rule { + target_label = "job" + replacement = "integrations/snowflake" + } +} + prometheus.scrape "integrations_snowflake" { - targets = prometheus.exporter.snowflake.integrations_snowflake.targets + targets = discovery.relabel.integrations_snowflake.output forward_to = [prometheus.remote_write.metrics_default.receiver] job_name = "integrations/snowflake" } @@ -396,8 +540,17 @@ prometheus.exporter.squid "integrations_squid" { address = "localhost:3128" } +discovery.relabel "integrations_squid" { + targets = prometheus.exporter.squid.integrations_squid.targets + + rule { + target_label = "job" + replacement = "integrations/squid" + } +} + prometheus.scrape "integrations_squid" { - targets = prometheus.exporter.squid.integrations_squid.targets + targets = discovery.relabel.integrations_squid.output forward_to = [prometheus.remote_write.metrics_default.receiver] job_name = "integrations/squid" scrape_timeout = "1m0s" @@ -405,8 +558,17 @@ prometheus.scrape "integrations_squid" { prometheus.exporter.statsd "integrations_statsd_exporter" { } +discovery.relabel "integrations_statsd" { + targets = prometheus.exporter.statsd.integrations_statsd_exporter.targets + + rule { + target_label = "job" + replacement = "integrations/statsd" + } +} + prometheus.scrape "integrations_statsd" { - targets = prometheus.exporter.statsd.integrations_statsd_exporter.targets + targets = discovery.relabel.integrations_statsd.output forward_to = [prometheus.remote_write.metrics_default.receiver] job_name = "integrations/statsd" } @@ -427,6 +589,11 @@ discovery.relabel "integrations_agent" { target_label = "test_label_2" replacement = "test_label_value_2" } + + rule { + target_label = "job" + replacement = "integrations/agent" + } } prometheus.scrape "integrations_agent" { @@ -446,6 +613,11 @@ discovery.relabel "integrations_apache1" { target_label = "instance" replacement = "apache1" } + + rule { + target_label = "job" + replacement = "integrations/apache_http" + } } prometheus.scrape "integrations_apache1" { @@ -475,6 +647,11 @@ discovery.relabel "integrations_apache2" { target_label = "instance" replacement = "apache2" } + + rule { + target_label = "job" + replacement = "integrations/apache_http" + } } prometheus.scrape "integrations_apache2" { @@ -520,8 +697,17 @@ prometheus.exporter.blackbox "integrations_blackbox" { probe_timeout_offset = "0s" } +discovery.relabel "integrations_blackbox" { + targets = prometheus.exporter.blackbox.integrations_blackbox.targets + + rule { + target_label = "job" + replacement = "integrations/blackbox" + } +} + prometheus.scrape "integrations_blackbox" { - targets = prometheus.exporter.blackbox.integrations_blackbox.targets + targets = discovery.relabel.integrations_blackbox.output forward_to = [prometheus.remote_write.metrics_default.receiver] job_name = "integrations/blackbox" } @@ -542,8 +728,17 @@ prometheus.exporter.snmp "integrations_snmp" { } } +discovery.relabel "integrations_snmp" { + targets = prometheus.exporter.snmp.integrations_snmp.targets + + rule { + target_label = "job" + replacement = "integrations/snmp" + } +} + prometheus.scrape "integrations_snmp" { - targets = prometheus.exporter.snmp.integrations_snmp.targets + targets = discovery.relabel.integrations_snmp.output forward_to = [prometheus.remote_write.metrics_default.receiver] job_name = "integrations/snmp" } @@ -561,6 +756,11 @@ discovery.relabel "integrations_vsphere" { target_label = "instance" replacement = "vsphere" } + + rule { + target_label = "job" + replacement = "integrations/vsphere" + } } prometheus.scrape "integrations_vsphere" { diff --git a/converter/internal/staticconvert/testdata-v2_windows/integrations_v2.river b/converter/internal/staticconvert/testdata-v2_windows/integrations_v2.river index 903d7f0c9a9c..4f9e09a37ed4 100644 --- a/converter/internal/staticconvert/testdata-v2_windows/integrations_v2.river +++ b/converter/internal/staticconvert/testdata-v2_windows/integrations_v2.river @@ -11,8 +11,17 @@ prometheus.remote_write "metrics_default" { prometheus.exporter.windows "integrations_windows_exporter" { } +discovery.relabel "integrations_windows" { + targets = prometheus.exporter.windows.integrations_windows_exporter.targets + + rule { + target_label = "job" + replacement = "integrations/windows" + } +} + prometheus.scrape "integrations_windows" { - targets = prometheus.exporter.windows.integrations_windows_exporter.targets + targets = discovery.relabel.integrations_windows.output forward_to = [prometheus.remote_write.metrics_default.receiver] job_name = "integrations/windows" } diff --git a/converter/internal/staticconvert/testdata/integrations.river b/converter/internal/staticconvert/testdata/integrations.river index 261ef76f228b..07875ba5fcea 100644 --- a/converter/internal/staticconvert/testdata/integrations.river +++ b/converter/internal/staticconvert/testdata/integrations.river @@ -1,7 +1,16 @@ prometheus.exporter.agent "integrations_agent" { } +discovery.relabel "integrations_agent" { + targets = prometheus.exporter.agent.integrations_agent.targets + + rule { + target_label = "job" + replacement = "integrations/agent" + } +} + prometheus.scrape "integrations_agent" { - targets = prometheus.exporter.agent.integrations_agent.targets + targets = discovery.relabel.integrations_agent.output forward_to = [prometheus.remote_write.integrations.receiver] job_name = "integrations/agent" @@ -26,8 +35,17 @@ prometheus.exporter.apache "integrations_apache_http" { scrape_uri = "http://0.0.0.0/server-status?auto" } +discovery.relabel "integrations_apache_http" { + targets = prometheus.exporter.apache.integrations_apache_http.targets + + rule { + target_label = "job" + replacement = "integrations/apache_http" + } +} + prometheus.scrape "integrations_apache_http" { - targets = prometheus.exporter.apache.integrations_apache_http.targets + targets = discovery.relabel.integrations_apache_http.output forward_to = [prometheus.remote_write.integrations.receiver] job_name = "integrations/apache_http" @@ -49,8 +67,17 @@ prometheus.exporter.blackbox "integrations_blackbox" { probe_timeout_offset = "0s" } +discovery.relabel "integrations_blackbox" { + targets = prometheus.exporter.blackbox.integrations_blackbox.targets + + rule { + target_label = "job" + replacement = "integrations/blackbox" + } +} + prometheus.scrape "integrations_blackbox" { - targets = prometheus.exporter.blackbox.integrations_blackbox.targets + targets = discovery.relabel.integrations_blackbox.output forward_to = [prometheus.remote_write.integrations.receiver] job_name = "integrations/blackbox" @@ -77,8 +104,17 @@ prometheus.exporter.snmp "integrations_snmp" { } } +discovery.relabel "integrations_snmp" { + targets = prometheus.exporter.snmp.integrations_snmp.targets + + rule { + target_label = "job" + replacement = "integrations/snmp" + } +} + prometheus.scrape "integrations_snmp" { - targets = prometheus.exporter.snmp.integrations_snmp.targets + targets = discovery.relabel.integrations_snmp.output forward_to = [prometheus.remote_write.integrations.receiver] job_name = "integrations/snmp" @@ -95,8 +131,17 @@ prometheus.exporter.azure "integrations_azure_exporter" { metrics = ["HttpRequestCount"] } +discovery.relabel "integrations_azure_exporter" { + targets = prometheus.exporter.azure.integrations_azure_exporter.targets + + rule { + target_label = "job" + replacement = "integrations/azure_exporter" + } +} + prometheus.scrape "integrations_azure_exporter" { - targets = prometheus.exporter.azure.integrations_azure_exporter.targets + targets = discovery.relabel.integrations_azure_exporter.output forward_to = [prometheus.remote_write.integrations.receiver] job_name = "integrations/azure_exporter" @@ -109,8 +154,17 @@ prometheus.scrape "integrations_azure_exporter" { prometheus.exporter.cadvisor "integrations_cadvisor" { } +discovery.relabel "integrations_cadvisor" { + targets = prometheus.exporter.cadvisor.integrations_cadvisor.targets + + rule { + target_label = "job" + replacement = "integrations/cadvisor" + } +} + prometheus.scrape "integrations_cadvisor" { - targets = prometheus.exporter.cadvisor.integrations_cadvisor.targets + targets = discovery.relabel.integrations_cadvisor.output forward_to = [prometheus.remote_write.integrations.receiver] job_name = "integrations/cadvisor" @@ -172,8 +226,17 @@ prometheus.exporter.cloudwatch "integrations_cloudwatch_exporter" { decoupled_scraping { } } +discovery.relabel "integrations_cloudwatch_exporter" { + targets = prometheus.exporter.cloudwatch.integrations_cloudwatch_exporter.targets + + rule { + target_label = "job" + replacement = "integrations/cloudwatch_exporter" + } +} + prometheus.scrape "integrations_cloudwatch_exporter" { - targets = prometheus.exporter.cloudwatch.integrations_cloudwatch_exporter.targets + targets = discovery.relabel.integrations_cloudwatch_exporter.output forward_to = [prometheus.remote_write.integrations.receiver] job_name = "integrations/cloudwatch_exporter" @@ -186,8 +249,17 @@ prometheus.scrape "integrations_cloudwatch_exporter" { prometheus.exporter.consul "integrations_consul_exporter" { } +discovery.relabel "integrations_consul_exporter" { + targets = prometheus.exporter.consul.integrations_consul_exporter.targets + + rule { + target_label = "job" + replacement = "integrations/consul_exporter" + } +} + prometheus.scrape "integrations_consul_exporter" { - targets = prometheus.exporter.consul.integrations_consul_exporter.targets + targets = discovery.relabel.integrations_consul_exporter.output forward_to = [prometheus.remote_write.integrations.receiver] job_name = "integrations/consul_exporter" @@ -210,6 +282,11 @@ discovery.relabel "integrations_dnsmasq_exporter" { target_label = "instance" replacement = "dnsmasq-a" } + + rule { + target_label = "job" + replacement = "integrations/dnsmasq_exporter" + } } prometheus.scrape "integrations_dnsmasq_exporter" { @@ -226,8 +303,17 @@ prometheus.scrape "integrations_dnsmasq_exporter" { prometheus.exporter.elasticsearch "integrations_elasticsearch_exporter" { } +discovery.relabel "integrations_elasticsearch_exporter" { + targets = prometheus.exporter.elasticsearch.integrations_elasticsearch_exporter.targets + + rule { + target_label = "job" + replacement = "integrations/elasticsearch_exporter" + } +} + prometheus.scrape "integrations_elasticsearch_exporter" { - targets = prometheus.exporter.elasticsearch.integrations_elasticsearch_exporter.targets + targets = discovery.relabel.integrations_elasticsearch_exporter.output forward_to = [prometheus.remote_write.integrations.receiver] job_name = "integrations/elasticsearch_exporter" @@ -244,8 +330,17 @@ prometheus.exporter.gcp "integrations_gcp_exporter" { extra_filters = ["loadbalancing.googleapis.com:resource.labels.backend_target_name=\"sample-value\""] } +discovery.relabel "integrations_gcp_exporter" { + targets = prometheus.exporter.gcp.integrations_gcp_exporter.targets + + rule { + target_label = "job" + replacement = "integrations/gcp_exporter" + } +} + prometheus.scrape "integrations_gcp_exporter" { - targets = prometheus.exporter.gcp.integrations_gcp_exporter.targets + targets = discovery.relabel.integrations_gcp_exporter.output forward_to = [prometheus.remote_write.integrations.receiver] job_name = "integrations/gcp_exporter" @@ -261,8 +356,17 @@ prometheus.exporter.github "integrations_github_exporter" { api_token = "ABCDEFGH-1234-ABCD-1234-ABCDEFGHIJKL" } +discovery.relabel "integrations_github_exporter" { + targets = prometheus.exporter.github.integrations_github_exporter.targets + + rule { + target_label = "job" + replacement = "integrations/github_exporter" + } +} + prometheus.scrape "integrations_github_exporter" { - targets = prometheus.exporter.github.integrations_github_exporter.targets + targets = discovery.relabel.integrations_github_exporter.output forward_to = [prometheus.remote_write.integrations.receiver] job_name = "integrations/github_exporter" @@ -275,8 +379,17 @@ prometheus.scrape "integrations_github_exporter" { prometheus.exporter.kafka "integrations_kafka_exporter" { } +discovery.relabel "integrations_kafka_exporter" { + targets = prometheus.exporter.kafka.integrations_kafka_exporter.targets + + rule { + target_label = "job" + replacement = "integrations/kafka_exporter" + } +} + prometheus.scrape "integrations_kafka_exporter" { - targets = prometheus.exporter.kafka.integrations_kafka_exporter.targets + targets = discovery.relabel.integrations_kafka_exporter.output forward_to = [prometheus.remote_write.integrations.receiver] job_name = "integrations/kafka_exporter" @@ -299,6 +412,11 @@ discovery.relabel "integrations_memcached_exporter" { target_label = "instance" replacement = "memcached-a" } + + rule { + target_label = "job" + replacement = "integrations/memcached_exporter" + } } prometheus.scrape "integrations_memcached_exporter" { @@ -337,6 +455,11 @@ discovery.relabel "integrations_mongodb_exporter" { target_label = "instance" replacement = "instance-key-value" } + + rule { + target_label = "job" + replacement = "integrations/mongodb_exporter" + } } prometheus.scrape "integrations_mongodb_exporter" { @@ -362,6 +485,11 @@ discovery.relabel "integrations_mssql" { target_label = "instance" replacement = "instance-key-value" } + + rule { + target_label = "job" + replacement = "integrations/mssql" + } } prometheus.scrape "integrations_mssql" { @@ -388,6 +516,11 @@ discovery.relabel "integrations_mysqld_exporter" { target_label = "instance" replacement = "server-a" } + + rule { + target_label = "job" + replacement = "integrations/mysqld_exporter" + } } prometheus.scrape "integrations_mysqld_exporter" { @@ -421,6 +554,11 @@ discovery.relabel "integrations_node_exporter" { target_label = "__address__" replacement = "localhost:8099" } + + rule { + target_label = "job" + replacement = "integrations/node_exporter" + } } prometheus.scrape "integrations_node_exporter" { @@ -453,8 +591,17 @@ prometheus.exporter.oracledb "integrations_oracledb" { connection_string = "oracle://user:password@localhost:1521/orcl.localnet" } +discovery.relabel "integrations_oracledb" { + targets = prometheus.exporter.oracledb.integrations_oracledb.targets + + rule { + target_label = "job" + replacement = "integrations/oracledb" + } +} + prometheus.scrape "integrations_oracledb" { - targets = prometheus.exporter.oracledb.integrations_oracledb.targets + targets = discovery.relabel.integrations_oracledb.output forward_to = [prometheus.remote_write.integrations.receiver] job_name = "integrations/oracledb" scrape_timeout = "1m0s" @@ -478,6 +625,11 @@ discovery.relabel "integrations_postgres_exporter" { target_label = "instance" replacement = "postgres-a" } + + rule { + target_label = "job" + replacement = "integrations/postgres_exporter" + } } prometheus.scrape "integrations_postgres_exporter" { @@ -499,8 +651,17 @@ prometheus.exporter.process "integrations_process_exporter" { } } +discovery.relabel "integrations_process_exporter" { + targets = prometheus.exporter.process.integrations_process_exporter.targets + + rule { + target_label = "job" + replacement = "integrations/process_exporter" + } +} + prometheus.scrape "integrations_process_exporter" { - targets = prometheus.exporter.process.integrations_process_exporter.targets + targets = discovery.relabel.integrations_process_exporter.output forward_to = [prometheus.remote_write.integrations.receiver] job_name = "integrations/process_exporter" @@ -524,6 +685,11 @@ discovery.relabel "integrations_redis_exporter" { target_label = "instance" replacement = "redis-2" } + + rule { + target_label = "job" + replacement = "integrations/redis_exporter" + } } prometheus.scrape "integrations_redis_exporter" { @@ -545,8 +711,17 @@ prometheus.exporter.snowflake "integrations_snowflake" { warehouse = "SNOWFLAKE_WAREHOUSE" } +discovery.relabel "integrations_snowflake" { + targets = prometheus.exporter.snowflake.integrations_snowflake.targets + + rule { + target_label = "job" + replacement = "integrations/snowflake" + } +} + prometheus.scrape "integrations_snowflake" { - targets = prometheus.exporter.snowflake.integrations_snowflake.targets + targets = discovery.relabel.integrations_snowflake.output forward_to = [prometheus.remote_write.integrations.receiver] job_name = "integrations/snowflake" @@ -561,8 +736,17 @@ prometheus.exporter.squid "integrations_squid" { address = "localhost:3128" } +discovery.relabel "integrations_squid" { + targets = prometheus.exporter.squid.integrations_squid.targets + + rule { + target_label = "job" + replacement = "integrations/squid" + } +} + prometheus.scrape "integrations_squid" { - targets = prometheus.exporter.squid.integrations_squid.targets + targets = discovery.relabel.integrations_squid.output forward_to = [prometheus.remote_write.integrations.receiver] job_name = "integrations/squid" scrape_timeout = "1m0s" @@ -576,8 +760,17 @@ prometheus.scrape "integrations_squid" { prometheus.exporter.statsd "integrations_statsd_exporter" { } +discovery.relabel "integrations_statsd_exporter" { + targets = prometheus.exporter.statsd.integrations_statsd_exporter.targets + + rule { + target_label = "job" + replacement = "integrations/statsd_exporter" + } +} + prometheus.scrape "integrations_statsd_exporter" { - targets = prometheus.exporter.statsd.integrations_statsd_exporter.targets + targets = discovery.relabel.integrations_statsd_exporter.output forward_to = [prometheus.remote_write.integrations.receiver] job_name = "integrations/statsd_exporter" diff --git a/converter/internal/staticconvert/testdata/unsupported.river b/converter/internal/staticconvert/testdata/unsupported.river index 95c5e192b55a..8c0909bb6c7f 100644 --- a/converter/internal/staticconvert/testdata/unsupported.river +++ b/converter/internal/staticconvert/testdata/unsupported.river @@ -24,8 +24,17 @@ logging { prometheus.exporter.statsd "integrations_statsd_exporter" { } +discovery.relabel "integrations_statsd_exporter" { + targets = prometheus.exporter.statsd.integrations_statsd_exporter.targets + + rule { + target_label = "job" + replacement = "integrations/statsd_exporter" + } +} + prometheus.scrape "integrations_statsd_exporter" { - targets = prometheus.exporter.statsd.integrations_statsd_exporter.targets + targets = discovery.relabel.integrations_statsd_exporter.output forward_to = [prometheus.remote_write.integrations.receiver] job_name = "integrations/statsd_exporter" } diff --git a/converter/internal/staticconvert/testdata_windows/integrations.river b/converter/internal/staticconvert/testdata_windows/integrations.river index 14c12b899530..2124e95df4b0 100644 --- a/converter/internal/staticconvert/testdata_windows/integrations.river +++ b/converter/internal/staticconvert/testdata_windows/integrations.river @@ -24,8 +24,17 @@ http { prometheus.exporter.windows "integrations_windows_exporter" { } +discovery.relabel "integrations_windows_exporter" { + targets = prometheus.exporter.windows.integrations_windows_exporter.targets + + rule { + target_label = "job" + replacement = "integrations/windows_exporter" + } +} + prometheus.scrape "integrations_windows_exporter" { - targets = prometheus.exporter.windows.integrations_windows_exporter.targets + targets = discovery.relabel.integrations_windows_exporter.output forward_to = [prometheus.remote_write.integrations.receiver] job_name = "integrations/windows_exporter" }