From 4a67698f7dbbfe65b437eea346f37ae77ad4efe1 Mon Sep 17 00:00:00 2001 From: Donia Chaiehloudj Date: Tue, 19 Jul 2022 13:18:51 +0200 Subject: [PATCH] fix pr comments and add doc --- .DS_Store | Bin 0 -> 8196 bytes README.md | 2 +- cmd/main.go | 6 +- cmd/prommetric/metric.go | 2 +- deploy/deploy.sh | 4 +- .../monitoring/dashboards/temp-hum-view.json | 624 +++++++++++++++++- doc/deploy.md | 44 +- doc/tinygo.md | 11 + 8 files changed, 649 insertions(+), 44 deletions(-) create mode 100644 .DS_Store create mode 100644 doc/tinygo.md diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..fc4d4bfe3b64ace869d499d333816dbe98edd522 GIT binary patch literal 8196 zcmeHML2uJA6n<{IHr)j30iOV_oBNsPma-~ebeZCRtGan-b|rmCoS z_znC8&ioPn3n%!Vot4<_c0?fTDSnRqeU9Jfm!vNvB2gQ69uaL4k%xnAWdqfU!sC1_ zm0a4xWC1=MMY0`4GQfFd3GF(Z0!{&^fK$LJ;1u{96u>*1i+9a?Uyr)lDc}_NFBRbD zgO7u4HMMhX)uRKIN&#RC=vD=7_0u2L=MLCvYUkRb2SsQqtfq=I#Sm%cAT%B0)f7M1 zR?|tSD`TGY$|B8BM4EUAU%^RKwRN>qz$vh-0O#%n+NLuKX=LT^2N>J_sfr?&u5i?& zF$EU-tA$=)phL_alcXVaO^aVmHGNcYOE#wai zSp*X6p#j#FnAqHzg=Kvb{Pj#6u|8ii`s69V)ng0Ax|paoJn5Jyr9>80fEO(qE&0J7 zXK_X4?Eq>?y0qqGpR-t=GlU=3J}ZA$;(|#sNWbTN3kFe`jCOXui(J02RxEiXZ^L`n z?8!-U)EbSGT5I@*&t6Iy1y}7>@G9(1PAhi~Wjtzyad)T)VW$ho+t*>-k&~Jn$DKrR zn|i=2d*##0z3Fs!Z+~ygfAV;Lw&hQs?(T4VZ#FA?cON`_c5-?i^<&9`posLnK)3Yy zqW+B5!tsmdFpgx*8_f7T1d-G>W#erXw=>(iPIX4nxeCP(kPxA1aj?k-r?QHJFyd`$ zV`J?=#*JX`i@0SZ@O{*FsKDcu*aSCa-&~hK2pHHBJ*Oi&qz1j9CN)en2ZDk2=oo8d zzgK(BN`1^IRi+cnd;s5%VR`k|+KF|_G71Rs?lmEqee@LR0=QW1*U(%w-#WkNbnpK~ z._ _ _ _ | | | ___ ._ _ | | | || ' || | | | - |/ ._>| ' | - |_| |_||_|_|\_. | |_|_|\___.|_|_| +🐓 |_| |_||_|_|\_. | |_|_|\___.|_|_|v 🐓 <___| " echo "---------------- 🏠 Create cluster tinyhen ----------------" @@ -17,6 +17,8 @@ kubectl apply -k deploy/monitoring # Install prometheus stack (Grafana, Prometheus operator, etc) echo "---------------- 🔎 Deploying kube prometheus stack with dashboard provider ----------------" +helm repo add prometheus-community https://prometheus-community.github.io/helm-charts +helm repo update helm install kube-prometheus-stack prometheus-community/kube-prometheus-stack --values deploy/monitoring/values.yaml --namespace monitoring # Deploy the prometheus service monitoring for the app diff --git a/deploy/monitoring/dashboards/temp-hum-view.json b/deploy/monitoring/dashboards/temp-hum-view.json index c5827e8..1c73b9d 100644 --- a/deploy/monitoring/dashboards/temp-hum-view.json +++ b/deploy/monitoring/dashboards/temp-hum-view.json @@ -24,9 +24,514 @@ "editable": true, "fiscalYearStartMonth": 0, "graphTooltip": 0, + "id": 28, "links": [], "liveNow": false, "panels": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "blue", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 0, + "y": 0 + }, + "id": 13, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "min" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "9.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "editorMode": "builder", + "exemplar": false, + "expr": "humidity_percent", + "instant": true, + "legendFormat": "__auto", + "range": false, + "refId": "A" + } + ], + "title": "Humidity Min Value", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "text", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 3, + "y": 0 + }, + "id": 14, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "mean" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "9.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "editorMode": "builder", + "exemplar": false, + "expr": "humidity_percent", + "instant": true, + "legendFormat": "__auto", + "range": false, + "refId": "A" + } + ], + "title": "Humidity Mean Value", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 6, + "y": 0 + }, + "id": 11, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "max" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "9.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "editorMode": "builder", + "exemplar": false, + "expr": "humidity_percent", + "instant": true, + "legendFormat": "__auto", + "range": false, + "refId": "A" + } + ], + "title": "Humidity Max Value", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "text", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 9, + "y": 0 + }, + "id": 6, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "9.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "editorMode": "builder", + "exemplar": false, + "expr": "humidity_percent", + "instant": true, + "legendFormat": "__auto", + "range": false, + "refId": "A" + } + ], + "title": "Humidity Last Value", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "blue", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 12, + "y": 0 + }, + "id": 12, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "min" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "9.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "editorMode": "builder", + "exemplar": false, + "expr": "temperature_celsius", + "instant": true, + "legendFormat": "__auto", + "range": false, + "refId": "A" + } + ], + "title": "Temperature Min Value", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "text", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 15, + "y": 0 + }, + "id": 10, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "mean" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "9.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "editorMode": "builder", + "exemplar": false, + "expr": "temperature_celsius", + "instant": true, + "legendFormat": "__auto", + "range": false, + "refId": "A" + } + ], + "title": "Temperature Mean Value", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 18, + "y": 0 + }, + "id": 8, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "max" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "9.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "editorMode": "builder", + "exemplar": false, + "expr": "temperature_celsius", + "instant": true, + "legendFormat": "__auto", + "range": false, + "refId": "A" + } + ], + "title": "Temperature Max Value", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "text", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 21, + "y": 0 + }, + "id": 7, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "mean" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "9.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "editorMode": "builder", + "exemplar": false, + "expr": "temperature_celsius", + "instant": true, + "legendFormat": "__auto", + "range": false, + "refId": "A" + } + ], + "title": "Temperature Last Value", + "type": "stat" + }, { "datasource": { "type": "prometheus", @@ -36,7 +541,9 @@ "fieldConfig": { "defaults": { "color": { - "mode": "continuous-GrYlRd" + "fixedColor": "blue", + "mode": "thresholds", + "seriesBy": "last" }, "custom": { "axisLabel": "humidity", @@ -44,13 +551,13 @@ "barAlignment": 0, "drawStyle": "line", "fillOpacity": 45, - "gradientMode": "opacity", + "gradientMode": "scheme", "hideFrom": { "legend": false, "tooltip": false, "viz": false }, - "lineInterpolation": "linear", + "lineInterpolation": "smooth", "lineStyle": { "fill": "solid" }, @@ -71,19 +578,41 @@ }, "decimals": 0, "displayName": "humidity", - "mappings": [], + "mappings": [ + { + "options": { + "0-40": { + "color": "green", + "index": 0 + } + }, + "type": "value" + } + ], "max": 100, "min": 0, "thresholds": { "mode": "absolute", "steps": [ { - "color": "green", + "color": "purple", "value": null }, { - "color": "red", - "value": 80 + "color": "blue", + "value": 20 + }, + { + "color": "green", + "value": 30 + }, + { + "color": "blue", + "value": 50 + }, + { + "color": "purple", + "value": 60 } ] }, @@ -95,19 +624,22 @@ "h": 9, "w": 12, "x": 0, - "y": 0 + "y": 3 }, "id": 4, "options": { "legend": { "calcs": [ - "last" + "last", + "mean", + "max", + "min" ], - "displayMode": "list", + "displayMode": "hidden", "placement": "right" }, "tooltip": { - "mode": "single", + "mode": "multi", "sort": "none" } }, @@ -124,7 +656,7 @@ "refId": "A" } ], - "title": "Humidity in percent", + "title": "Humidity (Percent)", "type": "timeseries" }, { @@ -132,11 +664,12 @@ "type": "prometheus", "uid": "prometheus" }, - "description": "Display the temperature in degree Celsius over the time.", + "description": "Display the humidity in percent over the time.", "fieldConfig": { "defaults": { "color": { - "mode": "continuous-BlYlRd", + "fixedColor": "blue", + "mode": "thresholds", "seriesBy": "last" }, "custom": { @@ -144,14 +677,17 @@ "axisPlacement": "auto", "barAlignment": 0, "drawStyle": "line", - "fillOpacity": 26, - "gradientMode": "opacity", + "fillOpacity": 45, + "gradientMode": "scheme", "hideFrom": { "legend": false, "tooltip": false, "viz": false }, - "lineInterpolation": "linear", + "lineInterpolation": "smooth", + "lineStyle": { + "fill": "solid" + }, "lineWidth": 1, "pointSize": 7, "scaleDistribution": { @@ -168,21 +704,42 @@ } }, "decimals": 0, - "displayName": "temperature", - "mappings": [], - "max": 40, - "min": -5, - "noValue": "na", + "displayName": "humidity", + "mappings": [ + { + "options": { + "0-40": { + "color": "green", + "index": 0 + } + }, + "type": "value" + } + ], + "max": 100, + "min": 0, "thresholds": { "mode": "absolute", "steps": [ { - "color": "green", + "color": "blue", "value": null }, + { + "color": "#6ED0E0", + "value": 15 + }, + { + "color": "#EAB839", + "value": 20 + }, + { + "color": "orange", + "value": 25 + }, { "color": "red", - "value": 80 + "value": 30 } ] }, @@ -194,19 +751,22 @@ "h": 9, "w": 12, "x": 12, - "y": 0 + "y": 3 }, - "id": 2, + "id": 9, "options": { "legend": { "calcs": [ - "last" + "last", + "mean", + "max", + "min" ], - "displayMode": "list", + "displayMode": "hidden", "placement": "right" }, "tooltip": { - "mode": "single", + "mode": "multi", "sort": "none" } }, @@ -235,13 +795,13 @@ "list": [] }, "time": { - "from": "now-1h", + "from": "now-5m", "to": "now" }, "timepicker": {}, "timezone": "", "title": "Henhouse monitoring", - "uid": "CUDtUgg4k", + "uid": "hgSFNcg4z", "version": 1, "weekStart": "" -} +} \ No newline at end of file diff --git a/doc/deploy.md b/doc/deploy.md index f0a1926..1804191 100644 --- a/doc/deploy.md +++ b/doc/deploy.md @@ -1,7 +1,5 @@ # Deploy -https://kind.sigs.k8s.io/docs/user/ingress#ingress-nginx - ## Create cluster ```bash kind create cluster --name tinyhen --config deploy/cluster-config.yaml @@ -24,7 +22,44 @@ kubectl cluster-info --context kind-tinyhen-test Not sure what to do next? 😅 Check out https://kind.sigs.k8s.io/docs/user/quick-start/ ``` +## Create namespace monitoring +```bash +kind create cluster --name tinyhen --config deploy/cluster-config.yaml +``` + +EExpected output: +```bash +``` + +## Deploy dashboard as configmao +```bash +kubectl apply -k deploy/monitoring +``` + +## Deploy Kube Prometheus Stack + +```bash +helm repo add prometheus-community https://prometheus-community.github.io/helm-charts +helm repo update +helm install kube-prometheus-stack prometheus-community/kube-prometheus-stack --values deploy/monitoring/values.yaml --namespace monitoring +``` + +## Deploy service monitoring + +```bash +kubectl apply -f deploy/monitoring/service_monitor.yaml +``` + +## Deploy app + +```bash +kubectl apply -f deploy/app.yaml +``` + ## Deploy ingress Nginx + +[Ingress Nginx documentation](https://kind.sigs.k8s.io/docs/user/ingress#ingress-nginx) + ```bash kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml ``` @@ -75,8 +110,3 @@ ingress-nginx-admission-create-82sdh 0/1 Completed 0 4m5s ingress-nginx-admission-patch-jj7xq 0/1 Completed 2 4m5s ingress-nginx-controller-5458c46d7d-xk6q8 1/1 Running 0 4m5s ``` - -## Deploy Kube Prometheus Stack - - -## Deploy application diff --git a/doc/tinygo.md b/doc/tinygo.md new file mode 100644 index 0000000..7b7e380 --- /dev/null +++ b/doc/tinygo.md @@ -0,0 +1,11 @@ +# TinyGo + +## Prerequisites + +## Installation + +## Flash a board + +## Read from serial + +## \ No newline at end of file