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

[Prometheus receiver] host.name attribute set to 0.0.0.0 #6465

Closed
mx-psi opened this issue Nov 30, 2021 · 1 comment · Fixed by #6476
Closed

[Prometheus receiver] host.name attribute set to 0.0.0.0 #6465

mx-psi opened this issue Nov 30, 2021 · 1 comment · Fixed by #6476
Labels
bug Something isn't working comp:prometheus Prometheus related issues comp: receiver Receiver

Comments

@mx-psi
Copy link
Member

mx-psi commented Nov 30, 2021

Describe the bug

When scraping internal metrics as documented here the metrics have a 0.0.0.0 hostname attribute set. The host.name semantic convention is described in the OpenTelemetry specification as:

Name of the host. On Unix systems, it may contain what the hostname command returns, or the fully qualified hostname, or another name specified by the user.

As e.g. Wikipedia says,

the address 0.0.0.0 is a non-routable meta-address used to designate an invalid, unknown or non-applicable target

so I would argue that this value does not follow the specification (it is not the name of any valid host).

Steps to reproduce

Follow the instructions here and add a logging exporter to the pipeline with logLevel debug (see below for full config). Run the Collector and wait a few seconds.

What did you expect to see?

The internal metrics had a valid hostname or no hostname at all.

What did you see instead?

Metric payloads had the host.name attribute set to 0.0.0.0. For example:

Resource labels:
     -> service.name: STRING(otelcol)
     -> host.name: STRING(0.0.0.0)
     -> instance: STRING(0.0.0.0:8888)
     -> port: STRING(8888)
     -> scheme: STRING(http)
     -> job: STRING(otelcol)
InstrumentationLibraryMetrics #0
InstrumentationLibrary
Metric #0
Descriptor:
     -> Name: otelcol_exporter_enqueue_failed_log_records
     -> Description: Number of log records failed to be added to the sending queue.
     -> Unit:
     -> DataType: Sum
     -> IsMonotonic: true
     -> AggregationTemporality: AGGREGATION_TEMPORALITY_CUMULATIVE
NumberDataPoints #0
Data point attributes:
     -> exporter: STRING(logging)
     -> service_instance_id: STRING(5e515c71-b05f-4735-88a8-9ecf5a4db707)
     -> service_version: STRING(latest)
StartTimestamp: 2021-11-30 15:21:30.96 +0000 UTC
Timestamp: 2021-11-30 15:21:30.96 +0000 UTC
Value: 0.000000

What version did you use?
Version: 61b5600
What config did you use?
Config:

receivers:
  prometheus:
    config:
      scrape_configs:
      - job_name: 'otelcol'
        scrape_interval: 10s
        static_configs:
        - targets: ['0.0.0.0:8888']
        metric_relabel_configs:
          - source_labels: [ __name__ ]
            regex: '.*grpc_io.*'
            action: drop
exporters:
  logging:
    loglevel: debug
service:
  pipelines:
    metrics:
      receivers: [prometheus]
      processors: []
      exporters: [logging]

Environment

not relevant (happens on any environment).

Additional context

This attribute is added by this function:

func createNodeAndResourcePdata(job, instance, scheme string) pdata.Resource {
host, port, err := net.SplitHostPort(instance)
if err != nil {
host = instance
}
resource := pdata.NewResource()
attrs := resource.Attributes()
attrs.UpsertString(conventions.AttributeServiceName, job)
attrs.UpsertString(conventions.AttributeHostName, host)
attrs.UpsertString(jobAttr, job)
attrs.UpsertString(instanceAttr, instance)
attrs.UpsertString(portAttr, port)
attrs.UpsertString(schemeAttr, scheme)
return resource
}

cc @Aneurysm9 @dashpole as CODEOWNERS

@mx-psi mx-psi added bug Something isn't working comp:prometheus Prometheus related issues comp: receiver Receiver labels Nov 30, 2021
@jpkrohling
Copy link
Member

I had a similar discussion on a recent PR, and the takeaway is that 0.0.0.0 on the client-side can be safely switched by 127.0.0.1, as it's the one IP that is always present. Given that 0.0.0.0 represents all the IPs on the host, 127.0.0.1 is part of that set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working comp:prometheus Prometheus related issues comp: receiver Receiver
Projects
None yet
2 participants