crowdsecurity / helm-charts

CrowdSec community kubernetes helm charts
MIT License
27 stars 33 forks source link

Add additionalLabels to serviceMonitors #177

Closed urbaman closed 2 months ago

urbaman commented 3 months ago

Please add an additionalLabels: tag to serviceMonitors, so people is able to add labels scraped by prometheus with prometheus.

Example:

additionalLabels:
  release: kube-prometheus-stack
github-actions[bot] commented 3 months ago

@urbaman: Thanks for opening an issue, it is currently awaiting triage.

If you haven't already, please provide the following information:

In the meantime, you can:

  1. Check Crowdsec Documentation to see if your issue can be self resolved.
  2. You can also join our Discord.
  3. Check Releases to make sure your agent is on the latest version.
Details I am a bot created to help the [crowdsecurity](https://github.com/crowdsecurity) developers manage community feedback and contributions. You can check out my [manifest file](https://github.com/crowdsecurity/helm-charts/blob/main/.github/governance.yaml) to understand my behavior and what I can do. If you want to use this for your project, you can check out the forked project [rr404/oss-governance-bot](https://github.com/rr404/oss-governance-bot) repository.
github-actions[bot] commented 3 months ago

@urbaman: There are no 'kind' label on this issue. You need a 'kind' label to start the triage process.

Details I am a bot created to help the [crowdsecurity](https://github.com/crowdsecurity) developers manage community feedback and contributions. You can check out my [manifest file](https://github.com/crowdsecurity/helm-charts/blob/main/.github/governance.yaml) to understand my behavior and what I can do. If you want to use this for your project, you can check out the forked project [rr404/oss-governance-bot](https://github.com/rr404/oss-governance-bot) repository.
LaurenceJJones commented 3 months ago

And this cannot be achieved via these labels?

https://github.com/crowdsecurity/helm-charts/blob/6bd1d202fa705775d928a1226bcc98c38ad6288d/charts/crowdsec/values.yaml#L25

https://github.com/crowdsecurity/helm-charts/blob/6bd1d202fa705775d928a1226bcc98c38ad6288d/charts/crowdsec/values.yaml#L327

https://github.com/crowdsecurity/helm-charts/blob/6bd1d202fa705775d928a1226bcc98c38ad6288d/charts/crowdsec/values.yaml#L180

I guess not? https://github.com/crowdsecurity/helm-charts/blob/main/charts/crowdsec/templates/agent-serviceMonitor.yaml btw I dont use k8s so just trying to probe more information.

urbaman commented 3 months ago

No, they should be added in the servicemonitor templates (the one you pointed to for example) in the metadata section, something like this:

Template:

metadata:
  name: {{ .Release.Name }}-agent-service
  namespace: {{ .Release.Namespace }}
  labels:
    {{- include "podLabels" . | nindent 4 }}
    app.kubernetes.io/component: agent
    {{- if .Values.agent.metrics.serviceMonitor.additionalLabels }}
{{ toYaml .Values.agent.metrics.serviceMonitor.additionalLabels | indent 4 }}
    {{- end }}

values.yaml:

metrics:
    enabled: false
    # -- Creates a ServiceMonitor so Prometheus will monitor this service
    # -- Prometheus needs to be configured to watch on all namespaces for ServiceMonitors
    # -- See the documentation: https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack#prometheusioscrape
    # -- See also: https://github.com/prometheus-community/helm-charts/issues/106#issuecomment-700847774
    serviceMonitor:
      enabled: false
      additionalLabels: {}

For both serviceMonitors.