Azure政策(网守)通过Prometheus和Grafana在AK上监视

发布于 2025-01-28 08:55:42 字数 1101 浏览 5 评论 0 原文

我已经通过Terraform启用了Azure策略,并应用于AKS群集。我可以看到豆荚已部署,启动并运行。我应用了内置的计划也有“审核”,以测试Azure策略在AKS群集上的工作方式。

$ kubectl get pods -n gatekeeper-system
NAME                                    READY   STATUS    RESTARTS   AGE
gatekeeper-audit-77754c7d8-g44qb        1/1     Running   0          44h
gatekeeper-controller-78cff9c89-7pftn   1/1     Running   0          44h
gatekeeper-controller-78cff9c89-8dsfg   1/1     Running   0          44h

我找到了一个仪表板 指标不同/缺失。不确定,因为,Azure管理此守门人!?。我在下面看到一些面板正在显示,Prometheus可以提供指标。例如,以下 OPA_SCORECARD_CORNTARANT_VIOLATIONS 不可避免。

如何正确通过Prometheus监视Azure策略

I have enabled azure policies via terraform and applied to AKS cluster. I can see pods are deployed, up and running. I applied in-built initiative here too with effect "audit" to test out how azure policies works on aks cluster.

$ kubectl get pods -n gatekeeper-system
NAME                                    READY   STATUS    RESTARTS   AGE
gatekeeper-audit-77754c7d8-g44qb        1/1     Running   0          44h
gatekeeper-controller-78cff9c89-7pftn   1/1     Running   0          44h
gatekeeper-controller-78cff9c89-8dsfg   1/1     Running   0          44h

I found a dashboard https://grafana.com/grafana/dashboards/15763

But some of the metrics are different/missing. Not sure, because, azure managing this gatekeeper!?. I see below some panel are displaying and metrics are available in prometheus. For example below opa_scorecard_constraint_violations not avilable.
enter image description here

How to monitor azure policies via prometheus properly

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

分開簡單 2025-02-04 08:55:42

我认为当您使用 azure策略(+gatekeeper)时,可以导出 opa_scorecard_constraint_violations 之类的指标,

但是您只需导出Gatekeeper指标,您只需要创建一个服务监视以击中适当的端点。

我的服务监视器看起来像这样:

apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
  labels:
    monitoring: prometheus
  name: gatekeeper-system-pod-monitor
  namespace: monitoring
spec:
  jobLabel: gatekeeper.sh/system
  namespaceSelector:
    matchNames:
    - gatekeeper-system
  podMetricsEndpoints:
  - honorLabels: true
    path: /metrics
    port: metrics
  selector:
    matchLabels:
      gatekeeper.sh/system: "yes"

Grafana屏幕截图:
度量

I don't think metrics like opa_scorecard_constraint_violations can be exported when you're using Azure Policies(+Gatekeeper)

However you can export gatekeeper metrics, you just need to create a service monitor to hit the proper endpoint.

My service monitor looks like this:

apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
  labels:
    monitoring: prometheus
  name: gatekeeper-system-pod-monitor
  namespace: monitoring
spec:
  jobLabel: gatekeeper.sh/system
  namespaceSelector:
    matchNames:
    - gatekeeper-system
  podMetricsEndpoints:
  - honorLabels: true
    path: /metrics
    port: metrics
  selector:
    matchLabels:
      gatekeeper.sh/system: "yes"

grafana screenshot:
metrics

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文