config-sync-quickstart/multirepo/root/acm-monitor/acm-prometheus-config.yaml (96 lines of code) (raw):
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# [START anthosconfig_config_sync_quickstart_multirepo_root_acm_monitor_service_account]
apiVersion: v1
kind: ServiceAccount
metadata:
name: prometheus-acm
namespace: monitoring
# [END anthosconfig_config_sync_quickstart_multirepo_root_acm_monitor_service_account]
---
# [START anthosconfig_config_sync_quickstart_multirepo_root_acm_monitor_cluster_role]
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: prometheus-acm
rules:
- apiGroups: [""]
resources:
- nodes
- services
- endpoints
- pods
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources:
- configmaps
verbs: ["get"]
- nonResourceURLs: ["/metrics"]
verbs: ["get"]
# [END anthosconfig_config_sync_quickstart_multirepo_root_acm_monitor_cluster_role]
---
# [START anthosconfig_config_sync_quickstart_multirepo_root_acm_monitor_cluster_role_binding]
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: prometheus-acm
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: prometheus-acm
subjects:
- kind: ServiceAccount
name: prometheus-acm
namespace: monitoring
# [END anthosconfig_config_sync_quickstart_multirepo_root_acm_monitor_cluster_role_binding]
---
# [START anthosconfig_config_sync_quickstart_multirepo_root_acm_monitor_prometheus]
apiVersion: monitoring.coreos.com/v1
kind: Prometheus
metadata:
name: acm
namespace: monitoring
labels:
prometheus: acm
spec:
replicas: 3
serviceAccountName: prometheus-acm
serviceMonitorSelector:
matchLabels:
prometheus: config-management
alerting:
alertmanagers:
- namespace: default
name: alertmanager
port: web
resources:
requests:
memory: 400Mi
# [END anthosconfig_config_sync_quickstart_multirepo_root_acm_monitor_prometheus]
---
# [START anthosconfig_config_sync_quickstart_multirepo_root_acm_monitor_service]
apiVersion: v1
kind: Service
metadata:
name: prometheus-acm
namespace: monitoring
labels:
prometheus: acm
spec:
type: NodePort
ports:
- name: web
nodePort: 31900
port: 9190
protocol: TCP
targetPort: web
selector:
app: prometheus
prometheus: acm
# [END anthosconfig_config_sync_quickstart_multirepo_root_acm_monitor_service]
---
# [START anthosconfig_config_sync_quickstart_multirepo_root_acm_monitor_service_monitor]
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: acm-service
namespace: monitoring
labels:
prometheus: config-management
spec:
selector:
matchLabels:
monitored: "true"
namespaceSelector:
matchNames:
# If you are using mono-repo mode, choose config-management-system
# If you are using multi-repo mode, choose config-management-monitoring
# - config-management-system
- config-management-monitoring
endpoints:
- port: metrics
interval: 10s
# [END anthosconfig_config_sync_quickstart_multirepo_root_acm_monitor_service_monitor]