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

[AMORO-2932] fix prometheus exporter issues in helm chart #2933

Merged
merged 3 commits into from
Jun 24, 2024

Conversation

XBaith
Copy link
Contributor

@XBaith XBaith commented Jun 17, 2024

Why are the changes needed?

Close #2932 .

Brief change log

  • Can report metrics via prometheus in k8s

How was this patch tested?

  • Add some test cases that check the changes thoroughly including negative and positive cases if possible

  • Add screenshots for manual tests if appropriate

  • Run test locally before making a pull request

Documentation

  • Does this pull request introduce a new feature? (no)
  • If yes, how is the feature documented? (not documented)

@XBaith XBaith requested a review from baiyangtx June 17, 2024 07:33
@github-actions github-actions bot added type:docs Improvements or additions to documentation type:build labels Jun 17, 2024
@Override
public String name() {
return "prometheus-exporter";
return "prometheus";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prometheus seems to be ambiguous. I am not sure if the service name must be the same with the plugin name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it is. AMS need to load the plugin class base on the name, and plugin name is same as property name in configmap

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I first used the -exporter suffix considering because that we might implement a reporter based on push-gateway in the future.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's problem for '-' in kubernetes ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'-' is valid, the problem is the name should be less than 15 characters

Copy link
Contributor Author

@XBaith XBaith Jun 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prometheus push-gateway has limitations for some scenarios and not suitable for long-lived jobs(refer to https://prometheus.io/docs/practices/pushing/#should-i-be-using-the-pushgateway). I suggest using prometheus operator + podmonitor for this purpose

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about prom-exporter? exporter seems to be an important part of the plugin name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zhoujinsong I think it's fine, as long as it's stated that it's an abbreviation of prometheus

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@baiyangtx How about adding a additional property portName which can be used as containerPort in deployment and port in podmonitor

plugin:
  metricReporters:
    - name: prometheus-exporter
      enabled: true
      properties:
        port: 7001
        portName: metrics # which is hereby normatively defined as https://datatracker.ietf.org/doc/html/rfc6335#section-5.1
        interval: 60s
      service:
        type: ClusterIP
        port: "7001"
        nodePort: ~
        annotations: {
          "prometheus.io/scrape": "true",
          "prometheus.io/path": "/metrics",
          "prometheus.io/port": "7001"
        }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
  labels:
    app.kubernetes.io/name: amoro-monitor
  name: amoro-monitor
spec:
  namespaceSelector:
    any: true
  podMetricsEndpoints:
    {{- range .Values.plugin.metricReporters }}
    - interval: {{ .properties.interval }}
      port: {{ .properties.portName }}
    {{- end}}
  selector:
    matchLabels:
      app.kubernetes.io/name: ams

@baiyangtx
Copy link
Contributor

In this PR, can we simply handle the problem and only adapt helm charts for promethues?

metricReporters:
    promethues-exporter:
        enabled: true
        port: 7001
        properties: ~

and in deployment.yaml

          ports:
            - name: rest
              containerPort: {{ .Values.server.rest.port }}
            - name: table
              containerPort: {{ .Values.server.table.port }}
            - name: optimizing
              containerPort: {{ .Values.server.optimizing.port }}
            {{- include "amoro.pod.container.ports" . | nindent 8 }}

and we can manager port in _pod.tpl

{{- define "amoro.pod.container.ports" -}}
            - name: rest
              containerPort: {{ .Values.server.rest.port }}
            - name: table
              containerPort: {{ .Values.server.table.port }}
            - name: optimizing
              containerPort: {{ .Values.server.optimizing.port }}
{{- if .Values.metricRepoerters.promethuesExporter.enabled -}} 
            - name: promethues
              containerPort: {{ .Values.metricRepoerters.promethuesExporter.port }}
{{- end -}}
{{- end -}}

@github-actions github-actions bot removed type:docs Improvements or additions to documentation type:build labels Jun 21, 2024
@XBaith
Copy link
Contributor Author

XBaith commented Jun 21, 2024

@baiyangtx PTAL

Copy link
Contributor

@baiyangtx baiyangtx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zhoujinsong zhoujinsong merged commit 109b9a0 into apache:master Jun 24, 2024
2 checks passed
@zhoujinsong
Copy link
Contributor

Thanks for the work. @XBaith
Thanks for the review. @baiyangtx

@XBaith XBaith deleted the fix-prometheus-exporter branch June 24, 2024 05:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Can not deploy prometheus reporter via helm chart
4 participants