[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-08-11 (世界標準時間)。"],[[["\u003cp\u003ePrometheus can be used to monitor Config Connector by scraping metrics from its service endpoints on port 8888, specifically \u003ccode\u003ecnrm-controller-manager-service\u003c/code\u003e and \u003ccode\u003ecnrm-resource-stats-recorder-service\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eConfig Connector's service endpoints are annotated with \u003ccode\u003eprometheus.io/scrape: "true"\u003c/code\u003e and \u003ccode\u003eprometheus.io/port: "8888"\u003c/code\u003e, and labeled with \u003ccode\u003ecnrm.cloud.google.com/monitored: "true"\u003c/code\u003e and \u003ccode\u003ecnrm.cloud.google.com/system: "true"\u003c/code\u003e, which you will use to configure Prometheus.\u003c/p\u003e\n"],["\u003cp\u003ePrometheus uses PromQL to query metrics, allowing you to monitor various aspects such as reconcile requests, resource status by kind and namespace, and the utilization of reconcile workers, as shown with the provided examples.\u003c/p\u003e\n"],["\u003cp\u003eConfig Connector provides various metrics like \u003ccode\u003econfigconnector_reconcile_requests_total\u003c/code\u003e and \u003ccode\u003econfigconnector_applied_resources_total\u003c/code\u003e, viewable in the Prometheus user interface by searching for the prefix \u003ccode\u003econfigconnector_\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eYou can optionally enable metrics to be aggregated by individual resources instead of just resource kind, but be aware that this will drastically increase the amount of storage required by Prometheus, and you may have to set up retention.\u003c/p\u003e\n"]]],[],null,["# Monitoring Config Connector with Prometheus\n===========================================\n\n*** ** * ** ***\n\nYou can use [Prometheus](https://prometheus.io/) to collect and show\nmetrics from Config Connector.\n\nBefore you begin\n----------------\n\nTo complete the steps in this page, you need to install Prometheus on your\ncluster. You can do this by:\n\n- Using the\n [Prometheus Operator provided by CoreOS](https://coreos.com/operators/prometheus/docs/latest/), or\n\n- Following the\n [Prometheus documentation](https://prometheus.io/docs/prometheus/latest/getting_started/)\n to configure your cluster for scraping.\n\nScraping metrics\n----------------\n\nPrometheus gathers metrics by *scraping* an HTTP endpoint. This section\ndescribes the Config Connector scrape endpoints and configuring\nPrometheus.\n\n### Config Connector scrape endpoints\n\nFor Config Connector, service endpoints are on port 8888 at\n`cnrm-controller-manager-service` and `cnrm-resource-stats-recorder-service`.\nThese services have the `prometheus.io/scrape: \"true\"` and\n`prometheus.io/port: \"8888\"` annotations. The services also include the labels\n`cnrm.cloud.google.com/monitored: \"true\"` and\n`cnrm.cloud.google.com/system: \"true\"`. You configure Prometheus to\nscrape Config Connector components from these annotations and labels.\n\n### Configuring Prometheus\n\nBefore you can scrape metrics, you might need to configure Prometheus for\n[Kubernetes Service Discovery (SD)](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#kubernetes_sd_config)\nto discover scrape targets from the Kubernetes REST API.\n\nHow you configure Prometheus to scrape metrics from Config Connector depends on\nhow you installed Prometheus. Check the documentation for your Prometheus\ninstallation for how to update configuration.\n\nFor example, If you are using the\nPrometheus Operator and configure it with\n[ServiceMonitor](https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/user-guides/basic-auth.md),\nyou can apply the following configuration to scrape metrics from\nConfig Connector. \n\n spec:\n endpoints:\n - interval: 10s\n port: metrics\n namespaceSelector:\n matchNames:\n - cnrm-system\n selector:\n matchLabels:\n cnrm.cloud.google.com/monitored: \"true\"\n cnrm.cloud.google.com/system: \"true\"\n\nExample queries\n---------------\n\nPrometheus uses a query language called\n[PromQL](https://prometheus.io/docs/prometheus/latest/querying/basics/).\nThis section contains example PromQL queries for Config Connector's metrics. You\ncan configure Prometheus to generate\n[alerts](https://prometheus.io/docs/alerting/overview/) from any\nvalid PromQL query.\n\n### Query reconcile requests by resource kind and status\n\nYou can see the count of failed reconcile requests by resource kind and status.\n\nFor example, to check the total count of errors for `PubSubTopic` resources, use\nthe following query. \n\n```\nconfigconnector_reconcile_requests_total{group_version_kind=\"PubSubTopic.pubsub.cnrm.cloud.google.com\", status=\"ERROR\"}\n```\n\n### Check the aggregate status of resources by kind and Namespace\n\nYou can see the count of resources that are in a Namespace.\n\nFor example, to check the total count of `PubSubTopic` resources in the\n`default` Namespace, use the following query. \n\n```\nconfigconnector_applied_resources_total{group_version_kind=\"PubSubTopic.pubsub.cnrm.cloud.google.com\", Namespace=\"default\"}\n```\n\n### Query the utilization of reconcile workers per resource kind\n\n```\n(configconnector_reconcile_occupied_workers_total / configconnector_reconcile_workers_total)\n```\n\nAvailable metrics\n-----------------\n\nConfig Connector collects the following metrics and makes them available.\n| **Note:** Additional metrics might be available. You can see the complete list in the Prometheus user interface by searching for the prefix `configconnector_`.\n\nEnabling resource name labels\n-----------------------------\n\n|\n| **Beta**\n|\n|\n| This product or feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA products and features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nBy default, metrics are aggregated on resource kind (for example, PubSubTopic).\nYou can enable metrics to be aggregated by individual resources.\n| **Note:** Enabling this option can dramatically increase the amount of data stored in Prometheus. Be sure you have enough storage space, or configure [retention](https://prometheus.io/docs/prometheus/latest/storage/#compaction).\n\nTo enable aggregation by resource name, perform the following steps.\n\n1. Edit the `cnrm-controller-manager` StatefulSet object\n\n ```\n kubectl edit statefulset cnrm-controller-manager -n cnrm-system\n ```\n\n If you are using\n [Namespaced mode](/config-connector/docs/concepts/installation-types),\n replace \u003cvar translate=\"no\"\u003eNAMESPACE_NAME\u003c/var\u003e with your Namespace. \n\n ```\n kubectl edit statefulset cnrm-controller-manager -n NAMESPACE_NAME\n ```\n2. Find the array `spec.args` and add `--resource-name-label=true`.\n\n apiVersion: apps/v1\n kind: StatefulSet\n name: cnrm-controller-manager\n spec:\n template:\n spec:\n containers:\n - name: manager\n args:\n - --resource-name-label=true\n\nWhat's next\n-----------\n\nFor more information on writing queries, see the Prometheus\n[Query language documentation](https://prometheus.io/docs/prometheus/latest/querying/basics/)\nand\n[Examples](https://prometheus.io/docs/prometheus/latest/querying/examples/)"]]