-
Add and then install the helm repo: link
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts helm repo update
helm install [RELEASE_NAME] prometheus-community/kube-prometheus-stack
Note: Our release name was
prometheus
, you can name it anything you want -
Run
kubectl get statefulset
You should see 2 stateful set's:
alertmanager-prometheus-kube-prometheus-alertmanager
andprometheus-prometheus-kube-prometheus-prometheus
-
Run these commands to see your stateful set YAML files:
kubectl describe statefulset prometheus-prometheus-kube-prometheus-prometheus > prom.yaml
kubectl describe statefulset alertmanager-prometheus-kube-prometheus-alertmanager > alert.yaml
-
Run this command to see your deployment:
kubectl get deployment
You should see this deployment:
prometheus-kube-prometheus-operator
-
Run this command to see your deployment YAML file:
kubectl describe deployment prometheus-kube-prometheus-operator > oper.yaml
-
Run this command to see your secret:
kubectl get secret
You should see this secret:
prometheus-prometheus-kube-prometheus-prometheus
-
Run this command to see your secret YAML file:
kubectl get secret prometheus-prometheus-kube-prometheus-prometheus -o yaml > secret.yaml
-
Take a look at your prom.yaml file, locate where it shows the rules file mounted. It should look something like this:
prometheus-prometheus-kube-prometheus-prometheus-rulefiles-0
-
Run this command to see your configmap YAML file:
kubectl get configmap prometheus-prometheus-kube-prometheus-prometheus-rulefiles-0 -o yaml > config.yaml
-
Run this command to see your pods:
kubectl get pods
You should see a prometheus-grafana pod like this:
prometheus-grafana-55985c774b-pjqlf
Note: Your pod name may appear different, follow what shows up on your terminal
-
Run this command to connect your pod to grafana
kubectl logs prometheus-grafana-55985c774b-pjqlf -c grafana
-
Run this command to access Grafana UI
kubectl port-forward deployment/prometheus-grafana 3001:3000
Note: This is port forwarded to localhost:3001 with a target port of 3000 because Grafana runs on port 3000, but our server is running on 3000 as well.
-
Go to localhost:3001 now, the Grafana UI should appear. The login credentials are
username: admin password: prom-operator
-
You should be able to see some metrics scraped by the node-exporter with some example dashboards
-
Run this command to see your services:
kubectl get service
-
Access Prometheus UI by running the command:
kubectl port-forward service/prometheus-kube-prometheus-prometheus 9090
-
Access Prometheus Alert UI by running this command:
kubectl port-forward service/prometheus-kube-prometheus-alertmanager 9093
-
You can now create your own promQL queries and dashboards!
-
In your Grafana UI, the allow_embedding is set to false. Follow these steps to enable it. To see these settings, they are located at the
Server Admin (lower left corner, shield logo) > settings > security, allow_embedding: false
-
Run this command
kubectl edit configmap -n default prometheus-grafana -o yaml
Note: DO NOT CLOSE THE VIM EDITOR
VIM Editor commands for reference: link
-
When the VIM editor opens, you should see a file location on the bottom, it would look something like this:
"/var/folders/7c/155484h133q1wyl5012jvvnm0000gn/T/kubectl-edit-1574205893.yaml" 40L, 1119B
-
Navigate to that location on your computer, make sure you have enabled viewing hidden files on your Mac with this command:
command + shift + .
-
You would navigate from
Macintosh HD > var > folders > 7c > 155484h133q1wyl5012jvvnm0000gn > T > kubectl-edit-1574205893.yaml
, double click on it and it should open in your VSCode -
Edit the YAML file in VSCode and add this below domain:
[security] allow_embedding: true [auth.anonymous] enabled: true
Save this file and keep it open for now
-
Go back to the VIM editor, it should show a command saying (O)K or (L)oad File. Press
L
for Load File and then enter:wq
. This should save the changes that you have currently made. -
Notice at the top of the Grafana UI server admin settings it says
"These system settings are defined in grafana.ini or custom.ini (or overridden in ENV variables). To change these you currently need to restart Grafana."
-
Run this command to get all pods
kubectl get po -A
-
Run this command to delete your current prometheus-grafana pod:
kubectl delete pod prometheus-grafana-55985c774b-pjqlf
Note: Don't worry, this pod is going to regenerate
-
Run this command to get all pods again
kubectl get po -A
-
Run this command to connect your new pod to grafana again:
kubectl logs prometheus-grafana-6fdd6868b4-vc7rk -c grafana
-
Run this command to access Grafana UI
kubectl port-forward deployment/prometheus-grafana 3001:3000
-
Now when you log back into the Grafana UI and go to
Server Admin (lower left corner, shield logo) > settings > security
, the allow_embedding should saytrue
-
To start embedding your own custom dashboard, click on the three dots on the top to share. You will see 4 options: Link, Snapshot, Embed, Library Panel. If you decide to use the
Embed
section with the iframe, replace the current src link with the link from theLink
section or else you will get a 404 error