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

[Bug] prometheus metric format is invalid #2354

Open
1 task done
qwtsc opened this issue Nov 18, 2023 · 8 comments
Open
1 task done

[Bug] prometheus metric format is invalid #2354

qwtsc opened this issue Nov 18, 2023 · 8 comments
Labels
bug Something isn't working

Comments

@qwtsc
Copy link
Contributor

qwtsc commented Nov 18, 2023

Bug Type (问题类型)

None

Before submit

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

Environment (环境信息)

hugegraph in k8s using prometheus and grafana as service monitor.

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

image
prometheus metrics format is invalid. After some investigations and code review, I think that the problem would probably be that this PR do not use the correct data exposition format that prometheus community required. The acceptable histogram format can be viewed as follows:

# A histogram, which has a pretty complex representation in the text format:
# HELP http_request_duration_seconds A histogram of the request duration.
# TYPE http_request_duration_seconds histogram
http_request_duration_seconds_bucket{le="0.05"} 24054
http_request_duration_seconds_bucket{le="0.1"} 33444
http_request_duration_seconds_bucket{le="0.2"} 100392
http_request_duration_seconds_bucket{le="0.5"} 129389
http_request_duration_seconds_bucket{le="1"} 133988
http_request_duration_seconds_bucket{le="+Inf"} 144320
http_request_duration_seconds_sum 53423
http_request_duration_seconds_count 144320

and I do also think the correct metric type here is supposed to be summary rather than histogram according to the prometheus best practice documentation.

By the way, I am willing to provide a PR to fix this issue as well as grafana dashboard configuration after I figure it out .

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

No response

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

No response

@qwtsc qwtsc added the bug Something isn't working label Nov 18, 2023
@qwtsc
Copy link
Contributor Author

qwtsc commented Nov 20, 2023

And metric name is also invalid. There are not allowed to have / or $, so this snippet of code should change to the following.

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

@JackyYangPassion
Copy link
Contributor

Hi @qwtsc , thanks for reporting the issue.
Welcome to submit PR for fixes

@imbajin
Copy link
Member

imbajin commented Nov 20, 2023

@SunnyBoy-WYH could u check the issue when free

@SunnyBoy-WYH
Copy link
Contributor

SunnyBoy-WYH commented Nov 20, 2023

@qwtsc Thanks for your report, welcome to submit PR ; but can you introduce the request path /param and something else that we can recurrent it ?

ref: https://hugegraph.apache.org/docs/clients/restful-api/metrics/#1-basic-metrics

@qwtsc
Copy link
Contributor Author

qwtsc commented Nov 21, 2023

@SunnyBoy-WYH the request path is just /metrics. check the following prometheus service monitor.

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: prometheus-hugegraph
  # Change this to the namespace the Prometheus instance is running in
  namespace: default
  labels:
    app: hugegraph
    release: prometheus
spec:
  selector:
    matchLabels:
      name: hugegraph
  namespaceSelector:
    matchNames:
    - hugegraph-e2e
  endpoints:
  - port: metrics
    path: /metrics
    interval: 15s

@SunnyBoy-WYH
Copy link
Contributor

@SunnyBoy-WYH the request path is just /metrics. check the following prometheus service monitor.

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: prometheus-hugegraph
  # Change this to the namespace the Prometheus instance is running in
  namespace: default
  labels:
    app: hugegraph
    release: prometheus
spec:
  selector:
    matchLabels:
      name: hugegraph
  namespaceSelector:
    matchNames:
    - hugegraph-e2e
  endpoints:
  - port: metrics
    path: /metrics
    interval: 15s

hi, will you continue to fix this issue ? @qwtsc

@SunnyBoy-WYH
Copy link
Contributor

how about this? but now we just let admin read metric, so we can config auth in prometheus.yml.; anything question?
image

@SunnyBoy-WYH
Copy link
Contributor

how about this? but if we open hg auth mode, we only let admin read metric, so we can config auth in prometheus.yml.; anything question? image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants