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

Metric name "_info" suffix gets trimmed #982

Open
iagotomas opened this issue Jun 29, 2024 · 4 comments
Open

Metric name "_info" suffix gets trimmed #982

iagotomas opened this issue Jun 29, 2024 · 4 comments
Assignees

Comments

@iagotomas
Copy link

Hi,
trying to implement a ruleset for some service, running jmx_exporter 1.0.1 as standalone I'm facing a weird issue which I'm not sure I understand.
I have the following rule for which the "_info" suffix in the name gets dropped. If I employ another suffix or add additional characters to the suffix "_info" it remains.

rules:
  #metrics:name=jvmInfo.runtime.{runtime}.vendor.{vendor}.version.{version},type=gauges
  - pattern: 'metrics<name=jvmInfo\.runtime\.(.+)\.vendor\.(.+)\.version\.(.*), type=gauges><>Value'
    labels:
      runtime: $1
      vendor: $2
      version: $3
    type: UNTYPED
    name: jvm_runtime_info
    help: "JVM info"

Resulting metric name:
jvm_runtime{runtime="OpenJDK_Runtime_Environment",vendor="Amazon.com_Inc.",version="17.0.7+7-LTS"} 1.0

Why does "_info" get removed from the name?

@dhoard dhoard self-assigned this Jul 1, 2024
@dhoard
Copy link
Collaborator

dhoard commented Jul 1, 2024

The relevant code is here...

PrometheusNaming.sanitizeMetricName(this.name),

@fstab, do you remember the specifics around why we sanitize the name?

@dhoard
Copy link
Collaborator

dhoard commented Oct 31, 2024

@fstab The code change was introduced as part of metric name collision work.

Do you remember the specifics?
Is it necessary?

@doxsch
Copy link
Contributor

doxsch commented Nov 11, 2024

We do have the same issue:

Beans:

kafka.schema.registry:type=avro-schemas-created
kafka.schema.registry:type=avro-schemas-deleted
kafka.schema.registry:type=json-schemas-created
kafka.schema.registry:type=json-schemas-deleted
kafka.schema.registry:type=protobuf-schemas-created
kafka.schema.registry:type=protobuf-schemas-deleted

Rule:

rules:
  - pattern: "kafka.schema.registry<type=(.+)-schemas-(.+)>([^:]+):"
    name: "kafka_schema_registry_schemas_$2"
    labels:
      schemaType: $1

returned metrics:

# HELP kafka_schema_registry_schemas Number of registered Avro schemas kafka.schema.registry:name=null,type=avro-schemas-created,attribute=avro-schemas-created
# TYPE kafka_schema_registry_schemas untyped
kafka_schema_registry_schemas{cluster="e1-kafka-pfnet-lab",schemaType="avro"} 0.0
kafka_schema_registry_schemas{cluster="e1-kafka-pfnet-lab",schemaType="json"} 0.0
kafka_schema_registry_schemas{cluster="e1-kafka-pfnet-lab",schemaType="protobuf"} 0.0

# HELP kafka_schema_registry_schemas_deleted Number of deleted Protobuf schemas kafka.schema.registry:name=null,type=protobuf-schemas-deleted,attribute=protobuf-schemas-deleted
# TYPE kafka_schema_registry_schemas_deleted untyped
kafka_schema_registry_schemas_deleted{cluster="e1-kafka-pfnet-lab",schemaType="avro"} 0.0
kafka_schema_registry_schemas_deleted{cluster="e1-kafka-pfnet-lab",schemaType="json"} 0.0
kafka_schema_registry_schemas_deleted{cluster="e1-kafka-pfnet-lab",schemaType="protobuf"} 0.0

The deleted metrics works but the created metric is trimmed.

@fstab
Copy link
Member

fstab commented Nov 11, 2024

Thanks for reporting this.

The reason is that the _info suffix is reserved for metrics of type INFO, but in the example the metric is

type: UNTYPED

Unfortunately I think type: INFO is not implemented in jmx_exporter. @dhoard would it be possible to add the INFO type? That would be the cleanest way to implement this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants