Skip to content

[Bug] Prometheus metrics format bug #3142

Description

@cui2022

Bug Type (问题类型)

None

Before submit

  • 我已经确认现有的 IssuesFAQ 中没有相同 / 重复问题 (I have confirmed and searched that there are no similar problems in the historical issue and documents)

Environment (环境信息)

3 pd
3 server
5 store

Expected & Actual behavior (期望与实际表现)

I pulled the latest version of the HugeGraph source code, compiled and deployed it, and then deployed a Prometheus + Grafana monitoring environment.

During the monitoring test, I found that the metrics exposed by hugegraph-server (/metrics) could not be scraped correctly by Prometheus. After checking the logs, I found that some metric names contained the illegal character ~, which does not comply with the Prometheus metric naming specification. As a result, Prometheus failed to parse the metrics data, causing the server monitoring metrics collection to fail.

I located the issue in the metric name processing logic and modified the related code to correctly replace the illegal characters in metric names. After recompiling and redeploying HugeGraph Server, the metrics format was fixed, and Prometheus was able to successfully scrape the server monitoring metrics.

public static String replaceSlashInKey(String orgKey) {
    return orgKey.replace("/", "_");
}
->
public static String replaceSlashInKey(String orgKey) {
    return orgKey.replace("/", "_").replace("~", "_");
}

I also modified the following code section. However, I am not sure whether this change has any effect. What I can confirm is that the code above definitely needs to be modified, because I first modified the code below, recompiled and redeployed the project, but the issue still occurred. After modifying the code above, recompiling and redeploying HugeGraph Server successfully resolved the problem.

public static String replaceDotDashInKey(String orgKey) {
return orgKey.replace(".", "").replace("-", "").replace("/", "").replace("$", "");
}
->
public static String replaceDotDashInKey(String orgKey) {
return orgKey.replace(".", "").replace("-", "").replace("/", "").replace("$", "").replace("~", "_");
}

Vertex/Edge example (问题点 / 边数据举例)

Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions