Any plan for a ServiceMonitor-like CRD?
Hi,
Coming from Prometheus Operator, I find it's sometime not ideal to configure Datadog integrations for Kubernetes workload by using either annotations on pods or autodiscovery in Datadog agent config.
Is there any plan to implement a CRD that would allow configuring integrations throught Kubernetes labels selectors without modifying the original workload or the Datadog agent?
@sebastien-prudhomme, thanks for submitting the issue!
Could you please provide more context about the request - what would be the CRD like, how would Operator use it and what gaps this setup could fill in current Autodiscovery mechanism?
This issue has been automatically marked as stale because it has not had activity in the past 15 days.
It will be closed in 30 days if no further activity occurs. If this issue is still relevant, adding a comment will keep it open. Also, you can always reopen the issue if you missed the window.
Thank you for your contributions!
I can add my 2c, since I would also like to see this feature. Currently for custom metrics, datadog annotations need to be added to a pod. Here is an example with cert-manager:
ad.datadoghq.com/cert-manager-controller.checks: |
{
"openmetrics": {
"init_config": {},
"instances": [
{
"openmetrics_endpoint": "http://%%host%%:9402/metrics",
"namespace": "cert_manager"
"metrics": [
"certificate.expiration_timestamp",
"certificate.ready_status",
"certificate.renewal_timestamp"
],
"tags": [
"component:controller",
"service:cert-manager",
"cluster_name:example-cluster",
"business:infra",
"env:prod"
]
}
]
}
}
This is a lot of data to cram into an annotation. Furthermore, because annotations can be any string, there is no type or schema validation. This can lead to misconfigurations which become cumbersome to debug.
In a similar fashion, this is why the Kubernetes Ingress resource is being deprecated in favor of the Gateway API.
The breadth and flexibility of Ingress NGINX has caused maintenance challenges. Changing expectations about cloud native software have also added complications. What were once considered helpful options have sometimes come to be considered serious security flaws, such as the ability to add arbitrary NGINX configuration directives via the "snippets" annotations. Yesterday’s flexibility has become today’s insurmountable technical debt.
The quote above addresses the security flaws of snippet annotations, but as many Kubernetes cluster maintainers can attest to, the sheer amount of Ingress annotations that could add up caused maintenance issues as well.
Instead, Datadog should create a CRD called DatadogCustomMetric which can reference a pod. Something like:
apiVersion: datadoghq.com/v1alpha1
kind: DatadogCustomMetric
metadata:
name: example-metric
namespace: example
spec:
container:
endpoint: /metrics # optional, defaults to /metrics
name: cert-manager-controller # required
port: 8080 # optional, defaults to 8080
datadogNamespacePrefix: cert_manager
metrics: # optional, defaults to all metrics
- metricName: certificate.expiration_timestamp
- metricName: certificate.ready_status
datadogMetricName: certificate.ready # optional, defaults to metricName
- metricName: certificate.renewal_timestamp
podSelector: # required
matchLabels:
app: cert-manager
tags: # optional
component:controller
service:cert-manager
cluster_name:example-cluster
business:infra
env:prod
Hi folks. Thanks for your patience and sorry for the delayed response.
A Datadog check CRD is on our radar and we're actively investigating what that looks like in the near future. Thanks for sharing your thoughts, it really helps shape our work and I hope to be back with more details soon. 🙂
I can add my 2c, since I would also like to see this feature. Currently for custom metrics, datadog annotations need to be added to a pod. Here is an example with cert-manager:
ad.datadoghq.com/cert-manager-controller.checks: | { "openmetrics": { "init_config": {}, "instances": [ { "openmetrics_endpoint": "http://%%host%%:9402/metrics", "namespace": "cert_manager" "metrics": [ "certificate.expiration_timestamp", "certificate.ready_status", "certificate.renewal_timestamp" ], "tags": [ "component:controller", "service:cert-manager", "cluster_name:example-cluster", "business:infra", "env:prod" ] } ] } }This is a lot of data to cram into an annotation. Furthermore, because annotations can be any string, there is no type or schema validation. This can lead to misconfigurations which become cumbersome to debug.
In a similar fashion, this is why the Kubernetes
Ingressresource is being deprecated in favor of the Gateway API.The breadth and flexibility of Ingress NGINX has caused maintenance challenges. Changing expectations about cloud native software have also added complications. What were once considered helpful options have sometimes come to be considered serious security flaws, such as the ability to add arbitrary NGINX configuration directives via the "snippets" annotations. Yesterday’s flexibility has become today’s insurmountable technical debt.
The quote above addresses the security flaws of snippet annotations, but as many Kubernetes cluster maintainers can attest to, the sheer amount of Ingress annotations that could add up caused maintenance issues as well.
Instead, Datadog should create a CRD called
DatadogCustomMetricwhich can reference a pod. Something like:apiVersion: datadoghq.com/v1alpha1 kind: DatadogCustomMetric metadata: name: example-metric namespace: example spec: container: endpoint: /metrics # optional, defaults to /metrics name: cert-manager-controller # required port: 8080 # optional, defaults to 8080 datadogNamespacePrefix: cert_manager metrics: # optional, defaults to all metrics
- metricName: certificate.expiration_timestamp
- metricName: certificate.ready_status datadogMetricName: certificate.ready # optional, defaults to metricName
- metricName: certificate.renewal_timestamp podSelector: # required matchLabels: app: cert-manager tags: # optional component:controller service:cert-manager cluster_name:example-cluster business:infra env:prod
While I really like that approach, I would like to see it enhanced so that it also would be possible to "emulate" not only the PodMonitor but the ServiceMonitor as well.
@stp-bsh There are fields in the PodMonitor and ServiceMonitor resources that wouldn't apply to Datadog custom metrics. What is the reason behind wanting to "emulate" these resources?
@starlightromero I would like to see Pod and ServiceMonitors emulated, as many users in the Kubernetes environment use Prometheus and are familiar with these two types of monitors. This also means that, in most cases, the software and deployments are specifically designed for them. Ideally, the Datadog Agent should not create something entirely new, but rather support existing environments in a minimally invasive way - preferably by utilizing the current infrastructure, which in this case includes Pod and ServiceMonitors.
@stp-bsh As much as I agree that many users use Prometheus, we shouldn't make the assumption that all users we have the Datadog Agent on their cluster will also have Prometheus. In other words, we don't want to make Prometheus a dependency of Datadog. This would mean not explicit using PodMonitors or ServiceMonitors.
However back to your emulation idea. I think it may be good to have the DatadogCustomMetric CRD have some similar fields to PodMonitor or ServiceMonitor CRDs. Although at this time I'm not sure which would be the most appropriate.
Yes plz, the CRDs that are already in place work great for us, extending the usage would be much appreciated 🙏