How to Scrape Prometheus Metrics from Okteto Insights using Prometheus Operator

How can I scrape Prometheus metrics from the Okteto Insights using the Prometheus Operator?

To scrape Prometheus metrics from Okteto Insights using Prometheus Operator, follow these steps:

  1. Ensure prerequisites:

    • Prometheus Operator is installed in the cluster, and its version is higher than 0.65.1.
    • The CRD for ScrapeConfig is correctly installed in the cluster.
  2. Apply the following ScrapeConfig manifest in the okteto namespace:

    apiVersion: monitoring.coreos.com/v1alpha1
    kind: ScrapeConfig
    metadata:
      name: okteto
      namespace: okteto
      labels:
        instance: okteto
    spec:
      staticConfigs:
      - targets:
        - okteto.yourinstancedomain.com:443
      scheme: HTTPS
      authorization:
        credentials:
          key: bearer
          name: okteto-insights
    

    Replace okteto.yourinstancedomain.com with your Okteto instance address. Refer to the following documentation for getting this value:

    If you customized your Helm release insights.bearerSecret configuration, replace spec.authorization.credentials accordingly. Refer to the following documentation for more information:

  3. Label the okteto namespace:

    kubectl label ns okteto prometheus-operator=okteto-insights
    
  4. Update your Prometheus Operator instance with the following sections:

    spec:
      scrapeConfigSelector:
        matchLabels:
          instance: okteto
      scrapeConfigNamespaceSelector:
        matchLabels:
          prometheus-operator: okteto-insights
    

These steps will configure your Prometheus Operator to scrape metrics from Okteto Insights.