update prometheus scraping part in readme
This commit is contained in:
parent
b099f15ff8
commit
b562a6717d
|
@ -54,7 +54,7 @@ nohup ./categraf &> stdout.log &
|
|||
```
|
||||
|
||||
|
||||
## Deploy categraf as daemonset
|
||||
## Deploy categraf as daemonset, deployment or sidecar
|
||||
|
||||
edit k8s/daemonset.yaml, replace NSERVER_SERVICE_WITH_PORT with service ip:port of nserver in your cluster, replace CATEGRAF_NAMESPACE with namespace value, then run:
|
||||
|
||||
|
@ -65,6 +65,8 @@ kubectl apply -n monitoring -f k8s/deployment.yaml #collect apiserver coredns et
|
|||
```
|
||||
Notice: k8s/sidecar.yaml is a demo, replace mock with your own image of service.
|
||||
|
||||
## Scrape like prometheus
|
||||
see detail [here](https://github.com/flashcatcloud/categraf/blob/main/prometheus/README.md)
|
||||
|
||||
## Plugin
|
||||
|
||||
|
|
|
@ -7,4 +7,74 @@ For more details, see the official docs:
|
|||
## Configuration
|
||||
|
||||
An [example](../conf/in_cluster_scrape.yaml) to scrape kube-apiserver and core-dns metrics .
|
||||
more examples click [here](https://github.com/prometheus/prometheus/tree/main/documentation/examples)
|
||||
more examples click [here](https://github.com/prometheus/prometheus/tree/main/documentation/examples)
|
||||
|
||||
|
||||
## How to create token
|
||||
|
||||
1. crate token ```kubectl apply -f auth.yaml```, replace CATEGRAF_NAMESPACE with your own in auth.yaml
|
||||
```
|
||||
### auth.yaml
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
annotations: {}
|
||||
labels:
|
||||
app: n9e
|
||||
component: categraf
|
||||
name: categraf-role
|
||||
rules:
|
||||
- apiGroups: [""]
|
||||
resources:
|
||||
- nodes
|
||||
- nodes/metrics
|
||||
- services
|
||||
- endpoints
|
||||
- pods
|
||||
verbs: ["get", "list", "watch"]
|
||||
- apiGroups:
|
||||
- extensions
|
||||
- networking.k8s.io
|
||||
resources:
|
||||
- ingresses
|
||||
verbs: ["get", "list", "watch"]
|
||||
- nonResourceURLs: ["/metrics", "/metrics/cadvisor"]
|
||||
verbs: ["get"]
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
annotations: {}
|
||||
labels:
|
||||
app: n9e
|
||||
component: categraf
|
||||
name: categraf-serviceaccount
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
annotations: {}
|
||||
labels:
|
||||
app: n9e
|
||||
component: categraf
|
||||
name: categraf-rolebinding
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: ClusterRole
|
||||
name: categraf-role
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: categraf-serviceaccount
|
||||
namespace: ${CATEGRAF_NAMESPACE}
|
||||
---
|
||||
```
|
||||
2. get token
|
||||
Scraping in cluster, token will be auto mount into pod with path ```/var/run/secrets/kubernetes.io/serviceaccount/token```, you do not need to care about it.
|
||||
|
||||
Scraping out of cluster, you can get token with this way and save it to file, then fill `bearer_token_file` in file `k8s/scrape_with_token.yaml`
|
||||
```
|
||||
secrets=$(kubectl get serviceaccount categraf-serviceaccount -o jsonpath={.secrets[].name})
|
||||
kubectl get secrets ${secrets} -o jsonpath={.data.token} | base64 -d
|
||||
```
|
||||
|
||||
|
|
Loading…
Reference in New Issue