diff --git a/charts/giropops-senhas/templates/service-giropops.yaml b/charts/giropops-senhas/templates/service-giropops.yaml index 6344824..6e9d417 100644 --- a/charts/giropops-senhas/templates/service-giropops.yaml +++ b/charts/giropops-senhas/templates/service-giropops.yaml @@ -3,6 +3,8 @@ kind: Service metadata: name: {{ .Values.giropops.service.name }} namespace: {{ .Values.namespace }} + labels: + app: {{ .Values.giropops.labels.app }} spec: selector: app: {{ .Values.giropops.labels.app }} @@ -10,4 +12,5 @@ spec: - protocol: {{ .Values.giropops.service.protocol }} port: {{ .Values.giropops.service.port }} targetPort: {{ .Values.giropops.service.port }} + name: {{ .Values.giropops.service.portName }} type: {{ .Values.giropops.service.type }} diff --git a/charts/giropops-senhas/values.yaml b/charts/giropops-senhas/values.yaml index 59719c1..1c59bf7 100644 --- a/charts/giropops-senhas/values.yaml +++ b/charts/giropops-senhas/values.yaml @@ -14,6 +14,7 @@ giropops: type: "ClusterIP" port: 5000 targetPort: 5000 + portName: "giropops-port" name: "giropops-senhas" protocol: "TCP" resources: diff --git a/monitoring/grafana-alert.json b/monitoring/grafana-alert.json new file mode 100644 index 0000000..357fc85 --- /dev/null +++ b/monitoring/grafana-alert.json @@ -0,0 +1,99 @@ +{ + "apiVersion": 1, + "groups": [ + { + "orgId": 1, + "name": "1m", + "folder": "giropops", + "interval": "1m", + "rules": [ + { + "uid": "bdx8i43bi8iyoc", + "title": "Giropops", + "condition": "C", + "data": [ + { + "refId": "A", + "relativeTimeRange": { + "from": 600, + "to": 0 + }, + "datasourceUid": "prometheus", + "model": { + "disableTextWrap": false, + "editorMode": "builder", + "expr": "kube_deployment_status_replicas{deployment=\"giropops-senhas\"}", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": true, + "intervalMs": 1000, + "legendFormat": "__auto", + "maxDataPoints": 43200, + "range": false, + "refId": "A", + "useBackend": false + } + }, + { + "refId": "C", + "relativeTimeRange": { + "from": 600, + "to": 0 + }, + "datasourceUid": "__expr__", + "model": { + "conditions": [ + { + "evaluator": { + "params": [ + 4 + ], + "type": "gt" + }, + "operator": { + "type": "and" + }, + "query": { + "params": [ + "C" + ] + }, + "reducer": { + "params": [], + "type": "last" + }, + "type": "query" + } + ], + "datasource": { + "type": "__expr__", + "uid": "__expr__" + }, + "expression": "A", + "intervalMs": 1000, + "maxDataPoints": 43200, + "refId": "C", + "type": "threshold" + } + } + ], + "noDataState": "NoData", + "execErrState": "Error", + "for": "1m", + "annotations": { + "description": "", + "runbook_url": "", + "summary": "Number of replicas is High!" + }, + "labels": { + "": "" + }, + "isPaused": false, + "notification_settings": { + "receiver": "grafana-default-email" + } + } + ] + } + ] +} diff --git a/monitoring/grafana-dashboard.json b/monitoring/grafana-dashboard.json new file mode 100644 index 0000000..5d87fc4 --- /dev/null +++ b/monitoring/grafana-dashboard.json @@ -0,0 +1,402 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": { + "type": "grafana", + "uid": "-- Grafana --" + }, + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 0, + "id": 29, + "links": [], + "panels": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "#EAB839", + "value": 70 + }, + { + "color": "dark-red", + "value": 80 + } + ] + }, + "unit": "percentunit" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "172.31.126.30:9100" + }, + "properties": [ + { + "id": "displayName", + "value": "Control-Plane" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "172.31.118.74:9100" + }, + "properties": [ + { + "id": "displayName", + "value": "Worker-3" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "172.31.116.95:9100" + }, + "properties": [ + { + "id": "displayName", + "value": "Worker-2" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "172.31.124.213:9100" + }, + "properties": [ + { + "id": "displayName", + "value": "Worker-1" + } + ] + } + ] + }, + "gridPos": { + "h": 5, + "w": 12, + "x": 0, + "y": 0 + }, + "id": 2, + "options": { + "minVizHeight": 75, + "minVizWidth": 75, + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true, + "sizing": "auto" + }, + "pluginVersion": "11.1.5", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "sum by(instance) (instance:node_memory_utilisation:ratio)", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "__auto", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Memory Usage - Node", + "type": "gauge" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 5, + "w": 12, + "x": 12, + "y": 0 + }, + "id": 9, + "options": { + "displayMode": "gradient", + "maxVizHeight": 300, + "minVizHeight": 16, + "minVizWidth": 8, + "namePlacement": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showUnfilled": true, + "sizing": "auto", + "valueMode": "color" + }, + "pluginVersion": "11.1.5", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "sum by(namespace) (node_namespace_pod:kube_pod_info:)", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "__auto", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Pods per Namespace", + "type": "bargauge" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 6, + "x": 0, + "y": 5 + }, + "id": 5, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "percentChangeColorMode": "standard", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "11.1.5", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "sum by(container) (senha_gerada_total)", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "__auto", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Passwords Generated - Total", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 24, + "x": 0, + "y": 11 + }, + "id": 10, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "11.1.4", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "sum by(container) (container_memory_usage_bytes)", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "__auto", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Memory Usage - POD", + "type": "timeseries" + } + ], + "refresh": "30s", + "schemaVersion": 39, + "tags": [], + "templating": { + "list": [] + }, + "time": { + "from": "now-1m", + "to": "now" + }, + "timepicker": {}, + "timezone": "browser", + "title": "Giropops-Senhas", + "uid": "fdw1pn87u5kaoc", + "version": 9, + "weekStart": "" +} diff --git a/monitoring/prometheus-svc-monitor.yaml b/monitoring/prometheus-svc-monitor.yaml new file mode 100644 index 0000000..c45752a --- /dev/null +++ b/monitoring/prometheus-svc-monitor.yaml @@ -0,0 +1,20 @@ +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: giropops-service-monitor + labels: + release: prometheus + app: prometheus +spec: + endpoints: + - interval: 30s + port: giropops-port + selector: + matchLabels: + app: giropops-senhas + namespaceSelector: + matchNames: + - giropops + - giropops-dev + - giropops-staging + - giropops-prod