Skip to content

Commit

Permalink
Merged in phstsai/node-exporter-readme (pull request #3)
Browse files Browse the repository at this point in the history
Phstsai/node exporter readme

Approved-by: Che Wei Lin <[email protected]>
Approved-by: Hung-Wei Chiu <[email protected]>

Former-commit-id: fec42ca552284137331d26f35a37c4596b5c9794 [formerly fec42ca552284137331d26f35a37c4596b5c9794 [formerly 3036a2e]]
Former-commit-id: 51d564d0dfbf48bdfd7dfe6b8f93eadd7ba52e24
Former-commit-id: 869f7ac
  • Loading branch information
WakeupTsai committed May 31, 2018
2 parents f414f33 + afb0823 commit afb2e42
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 5 deletions.
57 changes: 57 additions & 0 deletions deploy/monitoring/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Monitoring

## Prometheus
Prometheus is a systems and service monitoring system. It collects metrics from configured targets at given intervals, evaluates rule expressions, displays the results, and can trigger alerts if some condition is observed to be true.

### Create a monitoring namespace

``` bash
kubectl create -f monitoring-namespace.yaml
```

### ConfigMap for Prometheus
It collects metrics from ```kubernetes-apiservers```, ```kubernetes-cadvisor```, ```kubernetes-nodes```, ```kubernetes-pods```(every node-exporter), ```kubernetes-service-endpoints``` by default.

``` bash
kubectl create -f prometheus-config.yaml
```

### Create the deployment and service

``` bash
kubectl create -f prometheus-deployment.yaml
kubectl create -f prometheus-svc.yaml
```

### Use the Prometheus
Open the browser and connect to ```hostIP:30003```, you can see whether the Prometheus collect the metrics from targets correctly in ```Status->Targets```.

You also can enter a PromQL expression to query the data and show them in graph.

``` SQL
sum by(pod_name)(container_memory_usage_bytes{namespace="kube-system"})
```

Or pass the expression through url and get the json.
``` bash
http://hostIP:30003/api/v1/query?query=sum%20by(pod_name)(container_memory_usage_bytes%7Bnamespace%3D%22kube-system%22%7D)
```


## Node Exporter

Node exporter for machine metrics, written in Go with pluggable metric collectors.

### Create the node-exporter daemonset

``` bash
kubectl create -f node-exporter.yaml
```

If you want to check whether the daemonset is created successfully, you can create a service to expose the node-exporter.

``` bash
kubectl create -f node-exporter-svc.yaml
```

Open the browser and connect to ```hostIP:30910/metrics```, you can see the metrics of the host node (service will route the request to the pod in round robin order).
14 changes: 14 additions & 0 deletions deploy/monitoring/node-exporter-svc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
kind: Service
apiVersion: v1
metadata:
namespace: monitoring
name: node-exporter
labels:
app: node-exporter
spec:
type: NodePort
ports:
- port: 9100
nodePort: 30910
selector:
name: node-exporter
10 changes: 5 additions & 5 deletions deploy/monitoring/node-exporter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
namespace: monitoring
name: prom-node-exporter
name: node-exporter
spec:
template:
metadata:
name: prom-node-exporter
name: node-exporter
labels:
name: prom-node-exporter
name: node-exporter
annotations:
prometheus.io.scrape: "true"
spec:
hostPID: true
containers:
- name: prom-node-exporter
image: prom/node-exporter
- name: node-exporter
image: asia.gcr.io/linker-aurora/node-exporter:develop
securityContext:
privileged: true
ports:
Expand Down
File renamed without changes.

0 comments on commit afb2e42

Please sign in to comment.