Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #632 from david-martin/ocp_monitoring
Browse files Browse the repository at this point in the history
Add ocp_monitoring sub dir to prometheus-for-federation config
  • Loading branch information
openshift-ci[bot] authored Oct 19, 2023
2 parents 6965b6a + f8ce623 commit fcfb58b
Show file tree
Hide file tree
Showing 5 changed files with 690 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/prometheus-for-federation/ocp_monitoring/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/grafana_datasources.yaml
31 changes: 31 additions & 0 deletions config/prometheus-for-federation/ocp_monitoring/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Usage

To use this kustomization file with an OSD/OCP cluster, first get a token for
accessing the thanos-query instance, and generate a grafana datasource from the
template file

```shell
export SECRET=`oc get secret -n openshift-user-workload-monitoring | grep prometheus-user-workload-token | head -n 1 | awk '{print $1 }'`
export TOKEN=`echo $(oc get secret $SECRET -n openshift-user-workload-monitoring -o json | jq -r '.data.token') | base64 -d`
envsubst < ./config/prometheus-for-federation/ocp_monitoring/grafana_datasources.yaml.template > ./config/prometheus-for-federation/ocp_monitoring/grafana_datasources.yaml
```

Then apply the resources to the cluster:

```shell
kustomize --load-restrictor LoadRestrictionsNone build ./config/prometheus-for-federation/ocp_monitoring/ --enable-helm | kubectl apply -f -
```

Access Grafana on the exposed route, user/pass is admin/admin by default:

```shell
oc get route grafana -n monitoring
```

# Troubleshooting

If metrics are missing, check the targets in the OCP UI under Observe > Targets.
Each 'User' target corresponds to a ServiceMonitor or PodMonitor detected by the
user-workload-monitoring prometheus operator.
If a target is missing, check the logs of the prometheus operator in the
openshift-user-workload-monitoring namespace.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"apiVersion": 1,
"datasources": [
{
"access": "proxy",
"editable": false,
"name": "thanos-query",
"orgId": 1,
"type": "prometheus",
"url": "https://thanos-querier.openshift-monitoring.svc:9091",
"version": 1,
"jsonData": {
"httpHeaderName1": "Authorization",
"httpMethod": "POST",
"manageAlerts": false,
"tlsSkipVerify": true
},
"secureJsonData": {
"httpHeaderValue1": "Bearer $TOKEN"
}
}
]
}
36 changes: 36 additions & 0 deletions config/prometheus-for-federation/ocp_monitoring/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- monitoring.yaml
- github.com/Kuadrant/gateway-api-state-metrics?ref=main
- github.com/Kuadrant/gateway-api-state-metrics/config/examples/dashboards?ref=main

# Patch grafana deployment to include dashboard configmaps
patchesJson6902:
- target:
group: apps
version: v1
kind: Deployment
name: grafana
path: ../grafana_deployment_patch.yaml

generatorOptions:
disableNameSuffixHash: true

secretGenerator:
- name: grafana-datasources
namespace: monitoring
behavior: replace
files:
- grafana_datasources.yaml

configMapGenerator:
- name: grafana-istio-workload
namespace: monitoring
files:
- ../grafana_dashboard_istio-workload.json
- name: grafana-mgc-metrics
namespace: monitoring
files:
- ../grafana-dashboard-mgc-metrics.json
Loading

0 comments on commit fcfb58b

Please sign in to comment.