{"id":52343,"date":"2019-11-06T00:00:00","date_gmt":"2019-11-05T21:00:00","guid":{"rendered":"https:\/\/prohoster.info\/blog\/blog_prohoster\/razrabotka-plagina-dlya-grafana-istoriya-nabityh-shishek"},"modified":"2020-02-18T14:00:02","modified_gmt":"2020-02-18T11:00:02","slug":"razrabotka-plagina-dlya-grafana-istoriya-nabityh-shishek","status":"publish","type":"post","link":"https:\/\/prohoster.info\/sq\/blog\/administrirovanie\/razrabotka-plagina-dlya-grafana-istoriya-nabityh-shishek","title":{"rendered":"Zhvillimi i nj\u00eb plugin-i p\u00ebr Grafana: historia e m\u00ebsimeve t\u00eb marra","gt_translate_keys":[{"key":"rendered","format":"text"}]},"content":{"rendered":"<p>P\u00ebrsh\u00ebndetje t\u00eb gjith\u00ebve! Disa muaj m\u00eb par\u00eb ne lan\u00e7uam n\u00eb prodhim projektin ton\u00eb t\u00eb ri open-source \u2014 plugin-in Grafana p\u00ebr monitorimin e Kubernetes, t\u00eb cilin e quajt\u00ebm <b><noindex><a rel=\"nofollow\" href=\"https:\/\/grafana.com\/grafana\/plugins\/devopsprodigy-kubegraf-app\">DevOpsProdigy KubeGraf<\/a><\/noindex><\/b>. Kodi burimor i plugin-it \u00ebsht\u00eb n\u00eb dispozicion n\u00eb <noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/devopsprodigy\/kubegraf\">repo publik n\u00eb GitHub<\/a><\/noindex>. N\u00eb k\u00ebt\u00eb artikull ne duam t\u00eb ndajm\u00eb me ju historin\u00eb e m\u00ebnyr\u00ebs se si e krijuam plugin-in, cilat mjete p\u00ebrdor\u00ebm dhe me cilat v\u00ebshtir\u00ebsi u p\u00ebrball\u00ebm gjat\u00eb zhvillimit. Le t\u00eb fillojm\u00eb!<br \/>\n<noindex><a rel=\"nofollow\" name=\"habracut\"><\/a><\/noindex><\/p>\n<h4>Pjesa 0 \u2014 hyrje: si e arrit\u00ebm deri k\u00ebtu?<\/h4>\n<p>\nIdeja p\u00ebr t\u00eb shkruar plugin-in ton\u00eb p\u00ebr Grafan\u00ebn lindi krejt rast\u00ebsisht. Kompania jon\u00eb merret me monitorimin e projekteve web p\u00ebr m\u00eb shum\u00eb se 10 vjet. Gjat\u00eb k\u00ebsaj kohe ne kemi fituar nj\u00eb bagazh t\u00eb madh ekspertize, rastesh interesante, dhe p\u00ebrvojash n\u00eb p\u00ebrdorimin e sistemeve t\u00eb ndryshme t\u00eb monitorimit. Nd\u00ebrsa nj\u00eb moment ne na erdhi n\u00eb mendje pyetja: \"A ekziston ndonj\u00eb mjet magjik p\u00ebr monitorimin e Kubernetes-it, q\u00eb, si\u00e7 thuhet, 'e vendos dhe harro'\"? Standardi industrial p\u00ebr monitorimin e k8s, natyrisht, \u00ebsht\u00eb bashkimi Prometheus + Grafana. Dhe p\u00ebr zgjidhjet e gatshme p\u00ebr k\u00ebt\u00eb stack ekziston nj\u00eb grup i madh mjetesh t\u00eb ndryshme: prometheus-operator, grup dashboard-esh kubernetes-mixin, aplikacioni grafana-kubernetes. <\/p>\n<p>Opsioni m\u00eb interesant p\u00ebr ne dukej t\u00eb ishte plugin-i grafana-kubernetes-app, por ai nuk \u00ebsht\u00eb mb\u00ebshtetur p\u00ebr m\u00eb shum\u00eb se nj\u00eb vit dhe, p\u00ebrve\u00e7 k\u00ebsaj, nuk punon me versionet e reja t\u00eb node-exporter dhe kube-state-metrics. Nd\u00ebrsa nj\u00eb moment vendos\u00ebm: \"A nuk do ta b\u00ebnim ne zgjidhjen ton\u00eb?\"<\/p>\n<p>Cilat ide vendos\u00ebm t\u00eb realizojm\u00eb n\u00eb plugin-in ton\u00eb:<\/p>\n<ul>\n<li>vizualizimi i 'hart\u00ebs s\u00eb aplikacionit': p\u00ebrfaq\u00ebsim i p\u00ebrshtatsh\u00ebm i aplikacioneve n\u00eb kluster, t\u00eb grupuara sipas namespace-ve, deployment-eve\u2026;<\/li>\n<li>vizualizimi i lidhjeve t\u00eb tipit 'deployment \u2014 sh\u00ebrbim (+ports)'.<\/li>\n<li>vizualizimi i shp\u00ebrndarjes s\u00eb aplikacioneve t\u00eb klusterit sipas nod-eve t\u00eb klusterit.<\/li>\n<li>mbledhja e metrikave dhe informacionit nga disa burime: Prometheus dhe serveri i API t\u00eb k8s.<\/li>\n<li>monitorimi i pjes\u00ebs infrastrukturore (p\u00ebrdorimi i koh\u00ebs s\u00eb procesorit, memories, sistemit disk, rrjetit), si dhe logjik\u00ebs s\u00eb aplikacioneve \u2014 statusi i sh\u00ebndetit t\u00eb pod-eve, numri i replikave t\u00eb disponueshme, informacion mbi kalimin e testeve t\u00eb liveness\/readyness.<\/li>\n<\/ul>\n<p><\/p>\n<h4>Pjesa 1: \u00c7far\u00eb \u00ebsht\u00eb 'plugin p\u00ebr Grafana'?<\/h4>\n<p>\nNga k\u00ebndv\u00ebshtrimi teknik, nj\u00eb plugin p\u00ebr Grafana \u00ebsht\u00eb nj\u00eb kontrollues angular q\u00eb ruhet n\u00eb direktorin\u00eb data t\u00eb Grafan\u00ebs (<i>\/var\/grafana\/plugins\/&lt;your_plugin_name&gt;\/dist\/module.js<\/i>) dhe mund t\u00eb ngarkohet si nj\u00eb modul SystemJS. Gjithashtu, n\u00eb k\u00ebt\u00eb direktor duhet t\u00eb jet\u00eb nj\u00eb skedar plugin.json, q\u00eb p\u00ebrmban t\u00eb gjitha metainformacionet p\u00ebr plugin-in tuaj: emri, versioni, tipi i plugin-it, lidhjet me depot\/sit\u00eb\/licenc\u00eb, var\u00ebsit\u00eb dhe k\u00ebshtu me radh\u00eb.<\/p>\n<p><img decoding=\"async\" alt=\"Zhvillimi i nj\u00eb plugin-i p\u00ebr Grafana: historia e m\u00ebsimeve t\u00eb marra\" src=\"\/wp-content\/uploads\/2019\/11\/5993fec77a3904ed8b9e19a5addbb6ea.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<i>module.ts<\/i><\/p>\n<p><img decoding=\"async\" alt=\"Zhvillimi i nj\u00eb plugin-i p\u00ebr Grafana: historia e m\u00ebsimeve t\u00eb marra\" src=\"\/wp-content\/uploads\/2019\/11\/1e5b780837e5a9385e5e22a27d83f567.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<i>plugin.json<\/i><\/p>\n<p>Si\u00e7 shihet n\u00eb foto, ne kemi caktuar plugin.type = app. Sepse plugin-et p\u00ebr Grafana mund t\u00eb jen\u00eb t\u00eb tre llojeve:<\/p>\n<p><b>panel<\/b>: tipi m\u00eb i zakonsh\u00ebm i plugin-eve \u2014 p\u00ebrfaq\u00ebson nj\u00eb panel p\u00ebr vizualizimin e disa metrikave, p\u00ebrdoret p\u00ebr nd\u00ebrtimin e disa dashboard-eve t\u00eb ndryshme.<br \/>\n<b>datasource<\/b>: plugin-connector n\u00eb nj\u00eb burim t\u00eb dh\u00ebnash (p\u00ebr shembull, Prometheus-datasource, ClickHouse-datasource, ElasticSearch-datasource).<br \/>\n<b>app<\/b>: plugin q\u00eb ju lejon t\u00eb nd\u00ebrtoni aplikacionin tuaj t\u00eb frontend-it brenda Grafana, t\u00eb krijoni faqet tuaja html dhe t\u00eb b\u00ebni k\u00ebrkesa manuale n\u00eb datasource p\u00ebr vizualizimin e disa t\u00eb dh\u00ebnave t\u00eb ndryshme. Gjithashtu, si var\u00ebsi mund t\u00eb p\u00ebrdoren plugin-e t\u00eb lloje t\u00eb tjera (datasource, panel) dhe dashboard-e t\u00eb ndryshme.<\/p>\n<p><img decoding=\"async\" alt=\"Zhvillimi i nj\u00eb plugin-i p\u00ebr Grafana: historia e m\u00ebsimeve t\u00eb marra\" src=\"\/wp-content\/uploads\/2019\/11\/3cd53c7c3a2635f3f20831d52198b5f0.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<i>Shembulli i var\u00ebsive t\u00eb plugin-it me type = app<\/i>.<\/p>\n<p>Si gjuh\u00eb programimi mund t\u00eb p\u00ebrdoret si JavaScript, ashtu edhe TypeScript (ne e kemi zgjedhur at\u00eb). Skellet p\u00ebr plugin-e hello-world t\u00eb \u00e7do lloji mund t\u00eb <noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/CorpGlory\">gj\u00ebnden n\u00eb lidhje<\/a><\/noindex>: n\u00eb k\u00ebt\u00eb depo paraqitet nj\u00eb num\u00ebr i madh starter-pack\u2019ash (madje ka edhe nj\u00eb shembull eksperimental plugin-i n\u00eb React) me nd\u00ebrtues t\u00eb parainstaluar dhe t\u00eb konfiguruar. <\/p>\n<h4>Pjesa 2: p\u00ebrgatitja e mjedisit lokal<\/h4>\n<p>\nP\u00ebr t\u00eb punuar n\u00eb plugin, natyrisht, na nevojitet nj\u00eb grup kubernetes me t\u00eb gjitha mjete t\u00eb parainstaluara: prometheus, node-exporter, kube-state-metrics, grafana. Mjedisi duhet t\u00eb konfigurohet shpejt, leht\u00ebsisht dhe pa probleme, dhe p\u00ebr t\u00eb siguruar hot-reload, \u0434\u0438\u0440\u0435\u043a\u0442oria e t\u00eb dh\u00ebnave t\u00eb Grafana duhet t\u00eb montohet p\u00ebrmes kompjuterit t\u00eb zhvilluesit.<\/p>\n<p>M\u00eb i rehatshmi, sipas mendimit ton\u00eb, \u00ebsht\u00eb <noindex><a rel=\"nofollow\" href=\"https:\/\/kubernetes.io\/docs\/tasks\/tools\/install-minikube\/\">minikube<\/a><\/noindex>. Hapi tjet\u00ebr \u00ebsht\u00eb t\u00eb instalohet lidhja Prometheus + Grafana me an\u00eb t\u00eb prometheus-operator. N\u00eb <noindex><a rel=\"nofollow\" href=\"https:\/\/medium.com\/faun\/trying-prometheus-operator-with-helm-minikube-b617a2dccfa3\">k\u00ebt\u00eb artikull<\/a><\/noindex> p\u00ebrshkruhet n\u00eb detaje procesi i instalimit t\u00eb prometheus-operator n\u00eb minikube. P\u00ebr t\u00eb aktivizuar persistenc\u00ebn, duhet t\u00eb vendosni parametrin <i>persistence: true<\/i> n\u00eb skedarin charts\/grafana\/values.yaml, shtoni PV dhe PVC tuaj t\u00eb vet\u00ebdijsh\u00ebm dhe tregoni ato n\u00eb parametrin persistence.existingClaim<\/p>\n<p>Skema p\u00ebrfundimtare e nisjes s\u00eb minikube duket k\u00ebshtu:<\/p>\n<pre><code class=\"plaintext\">minikube start --kubernetes-version=v1.13.4 --memory=4096 --bootstrapper=kubeadm --extra-config=scheduler.address=0.0.0.0 --extra-config=controller-manager.address=0.0.0.0\nminikube mount \n\/home\/sergeisporyshev\/Projects\/Grafana:\/var\/grafana --gid=472 --uid=472 --9p-version=9p2000.L<\/code><\/pre>\n<p><\/p>\n<h4>Pjesa 3: zhvillimi i drejtp\u00ebrdrejt\u00eb<\/h4>\n<p>\n<b>Modeli i Objektit<\/b><\/p>\n<p>Si p\u00ebrgatitje p\u00ebr implementimin e plugin-it, ne vendos\u00ebm t\u00eb p\u00ebrshkruajm\u00eb t\u00eb gjitha entitetet baz\u00eb t\u00eb Kubernetes me t\u00eb cilat do t\u00eb punojm\u00eb n\u00eb form\u00ebn e klasave TypeScript: pod, deployment, daemonset, statefulset, job, cronjob, service, node, namespace. Secila nga k\u00ebto klasa trash\u00ebgon nga klasa e p\u00ebrbashk\u00ebt BaseModel, e cila p\u00ebrshkruan konstruktorin, destruktorin dhe metodat p\u00ebr p\u00ebrdit\u00ebsimin dhe ndryshimin e dukshm\u00ebris\u00eb. N\u00eb secil\u00ebn nga klasat p\u00ebrshkruhen marr\u00ebdh\u00ebniet e ngulitura me entitete t\u00eb tjera, p\u00ebr shembull, lista e pod-eve p\u00ebr entitetin e tipit deployment.<\/p>\n<pre><code class=\"plaintext\">import {Pod} from \".\/pod\";\nimport {Service} from \".\/service\";\nimport {BaseModel} from '.\/traits\/baseModel';\n\nexport class Deployment extends BaseModel{\n   pods: Array;\n   services: Array;\n\n   constructor(data: any){\n       super(data);\n       this.pods = [];\n       this.services = [];\n   }\n}<\/code><\/pre>\n<p>\nMe an\u00eb t\u00eb getter\u2019ave dhe setter\u2019ave, ne mund t\u00eb nxjerrim ose vendosim metrikat e nevojshme t\u00eb entiteteve n\u00eb nj\u00eb format t\u00eb p\u00ebrshtatsh\u00ebm dhe t\u00eb lexuesh\u00ebm. P\u00ebr shembull, output-i i formatizuar i allocatable cpu t\u00eb nod\u00ebs:<\/p>\n<pre><code class=\"plaintext\">get cpuAllocatableFormatted(){\n   let cpu = this.data.status.allocatable.cpu;\n   if(cpu.indexOf('m') &gt; -1){\n       cpu = parseInt(cpu)\/1000;\n   }\n   return cpu;\n}<\/code><\/pre>\n<p>\n<b>Faqet<\/b><\/p>\n<p>Lista e t\u00eb gjitha faqeve t\u00eb plugin-it ton\u00eb p\u00ebrshkruhet fillimisht n\u00eb pluing.json n\u00eb seksionin e var\u00ebsive:<\/p>\n<p><img decoding=\"async\" alt=\"Zhvillimi i nj\u00eb plugin-i p\u00ebr Grafana: historia e m\u00ebsimeve t\u00eb marra\" src=\"\/wp-content\/uploads\/2019\/11\/b86c74839ad0d9c64b97ffc3f2a84bdf.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\nN\u00eb bllokun p\u00ebr secil\u00ebn faqe, ne duhet t\u00eb specifikojm\u00eb EMRIN E FAQES (ky do t\u00eb konvertohet m\u00eb pas n\u00eb slug, me t\u00eb cilin do t\u00eb jet\u00eb e accesueshme kjo faqe); emrin e komponentit, i cili \u00ebsht\u00eb p\u00ebrgjegj\u00ebs p\u00ebr funksionimin e k\u00ebsaj faqe (lista e komponent\u00ebve eksporton n\u00eb module.ts); p\u00ebrcaktimin e rolit t\u00eb p\u00ebrdoruesit, p\u00ebr t\u00eb cilin \u00ebsht\u00eb e aksesuar puna me k\u00ebt\u00eb faqe dhe konfigurimet e navigimit p\u00ebr panelin an\u00ebsor. <\/p>\n<p>N\u00eb komponentin q\u00eb \u00ebsht\u00eb p\u00ebrgjegj\u00ebs p\u00ebr funksionimin e faqes, ne duhet t\u00eb vendosim templateUrl, duke kaluar aty rrug\u00ebn deri n\u00eb skedarin html me markup. Brenda kontrolluesit, p\u00ebrmes injeksionit t\u00eb var\u00ebsive, ne mund t\u00eb kemi qasje n\u00eb 2 sh\u00ebrbime t\u00eb r\u00ebnd\u00ebsishme t\u00eb angular:<\/p>\n<ul>\n<li>backendSrv \u2014 sh\u00ebrbimi q\u00eb siguron nd\u00ebrveprimin me serverin api t\u00eb Grafana;<\/li>\n<li>datasourceSrv \u2014 sh\u00ebrbimi q\u00eb siguron nd\u00ebrveprimin lokal me t\u00eb gjitha datasource-t q\u00eb jan\u00eb instaluar n\u00eb Grafana tuaj (p\u00ebr shembull, metoda .getAll() \u2014 kthen nj\u00eb list\u00eb t\u00eb t\u00eb gjitha datasource-ve t\u00eb instaluara; .get() \u2014 kthen objektin-instanc\u00ebn e nj\u00eb datasource-i t\u00eb caktuar.<\/li>\n<\/ul>\n<p>\n<img decoding=\"async\" alt=\"Zhvillimi i nj\u00eb plugin-i p\u00ebr Grafana: historia e m\u00ebsimeve t\u00eb marra\" src=\"\/wp-content\/uploads\/2019\/11\/e616e74c2e31ca3a81b7ed91ca333208.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\n<img decoding=\"async\" alt=\"Zhvillimi i nj\u00eb plugin-i p\u00ebr Grafana: historia e m\u00ebsimeve t\u00eb marra\" src=\"\/wp-content\/uploads\/2019\/11\/5e1d45f570dda50774088405abb41c9f.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\n<img decoding=\"async\" alt=\"Zhvillimi i nj\u00eb plugin-i p\u00ebr Grafana: historia e m\u00ebsimeve t\u00eb marra\" src=\"\/wp-content\/uploads\/2019\/11\/c072867623824e799518984c7b1bee93.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<\/p>\n<h4>Pjesa 4: datasource<\/h4>\n<p>\nSipas Grafana, nj\u00eb burim t\u00eb dh\u00ebnash \u00ebsht\u00eb i nj\u00ebjt\u00eb si \u00e7do plugin tjet\u00ebr: ai ka hyrjen e tij module.js, ka nj\u00eb sked\u00eb me metainformata plugin.json. Kur zhvillojm\u00eb nj\u00eb plugin me tipin = app, mund t\u00eb interaktojm\u00eb me burime ekzistuese t\u00eb dh\u00ebnash (p.sh. prometheus-datasource) si dhe me t\u00eb tuat, t\u00eb cilat mund t'i mbajm\u00eb direkt n\u00eb direktorin\u00eb e plugin-it (dist\/datasource\/*) ose t'i installojm\u00eb si var\u00ebsi. N\u00eb rastin ton\u00eb, burimi i t\u00eb dh\u00ebnave vjen s\u00eb bashku me kodin e plugin-it. Gjithashtu, \u00ebsht\u00eb e domosdoshme q\u00eb t\u00eb kemi nj\u00eb model config.html dhe kontrolluesin ConfigCtrl, t\u00eb cilat do t\u00eb p\u00ebrdoren p\u00ebr faqen e konfigurimit t\u00eb instanc\u00ebs s\u00eb burimit t\u00eb t\u00eb dh\u00ebnave dhe kontrolluesin e Burimit t\u00eb t\u00eb Dh\u00ebnave, n\u00eb t\u00eb cilin implementohet logjika e funksionimit t\u00eb burimit t\u00eb dh\u00ebnave.<\/p>\n<p>N\u00eb plugin-in KubeGraf, nga pik\u00ebpamja e nd\u00ebrfaqes s\u00eb p\u00ebrdoruesit, burimi i t\u00eb dh\u00ebnave p\u00ebrfaq\u00ebson nj\u00eb instanc\u00eb t\u00eb klasterit kubernetes, n\u00eb t\u00eb cilin jan\u00eb implementuar funksionalitetet e m\u00ebposhtme (kodin burimor e ka n\u00eb dispozicion <noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/devopsprodigy\/kubegraf\/tree\/master\/src\/datasource\">n\u00eb lidhje<\/a><\/noindex>):<\/p>\n<ul>\n<li>marrja e t\u00eb dh\u00ebnave nga api-server i k8s (marrja e list\u00ebs s\u00eb namespace-ve, deploymenteve\u2026)<\/li>\n<li>proksimi i k\u00ebrkesave p\u00ebr burimin e t\u00eb dh\u00ebnave prometheus (i zgjedhur n\u00eb konfigurimet e plugin-it p\u00ebr \u00e7do klaster specifik) dhe formatimi i p\u00ebrgjigjeve p\u00ebr p\u00ebrdorimin e t\u00eb dh\u00ebnave si n\u00eb faqet statike ashtu edhe n\u00eb panel\u00ebt e kontrollit.<\/li>\n<li>p\u00ebrdit\u00ebsimi i t\u00eb dh\u00ebnave n\u00eb faqet statike t\u00eb plugin-it (me nj\u00eb koh\u00eb t\u00eb caktuar refresh rate).<\/li>\n<li>p\u00ebrpunimi i k\u00ebrkesave p\u00ebr formimin e list\u00ebs s\u00eb templates n\u00eb grafana-dashboards (metoda .metriFindQuery())<\/li>\n<\/ul>\n<p>\n<img decoding=\"async\" alt=\"Zhvillimi i nj\u00eb plugin-i p\u00ebr Grafana: historia e m\u00ebsimeve t\u00eb marra\" src=\"\/wp-content\/uploads\/2019\/11\/18159bbb41144ebceb457df28b35e7b1.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\n<img decoding=\"async\" alt=\"Zhvillimi i nj\u00eb plugin-i p\u00ebr Grafana: historia e m\u00ebsimeve t\u00eb marra\" src=\"\/wp-content\/uploads\/2019\/11\/a62665b4409566fbe24f56f88a376d5a.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\n<img decoding=\"async\" alt=\"Zhvillimi i nj\u00eb plugin-i p\u00ebr Grafana: historia e m\u00ebsimeve t\u00eb marra\" src=\"\/wp-content\/uploads\/2019\/11\/7f2d61fce623ce2a3cf62feb6d0447ac.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<\/p>\n<ul>\n<li>testimi i lidhjes me klasterin p\u00ebrfundimtar k8s.<\/li>\n<\/ul>\n<pre><code class=\"plaintext\">testDatasource(){\n   let url = '\/api\/v1\/namespaces';\n   let _url = this.url;\n   if(this.accessViaToken)\n       _url += '\/__proxy';\n   _url += url;\n   return this.backendSrv.datasourceRequest({\n       url: _url,\n       method: \"GET\",\n       headers:{\"Content-Type\": 'application\/json'}\n   })\n       .then(response =&gt; {\n           if (response.status === 200) {\n               return {status: \"success\", message: \"Burimi i t\u00eb dh\u00ebnave \u00ebsht\u00eb OK\", title: \"Sukses\"};\n           }else{\n               return {status: \"error\", message: \"Burimi i t\u00eb dh\u00ebnave nuk \u00ebsht\u00eb OK\", title: \"Gabim\"};\n           }\n       }, error =&gt; {\n           return {status: \"error\", message: \"Burimi i t\u00eb dh\u00ebnave nuk \u00ebsht\u00eb OK\", title: \"Gabim\"};\n       })\n}<\/code><\/pre>\n<p>\nNj\u00eb moment interesant, sipas mendimit ton\u00eb, \u00ebsht\u00eb implementimi i mekanizmit t\u00eb autentifikimit dhe autorizimit p\u00ebr datasource. Zakonisht, nga kutia, p\u00ebr konfigurimin e aksesit n\u00eb burimin e fundit t\u00eb t\u00eb dh\u00ebnave, mund t\u00eb p\u00ebrdorim komponentin e integruar t\u00eb Grafana \u2014 datasourceHttpSettings. Me k\u00ebt\u00eb komponent mund t\u00eb konfigurojm\u00eb qasjen n\u00eb burimin e t\u00eb dh\u00ebnave http, duke specifikuar url dhe parametrat baz\u00eb t\u00eb autentifikimit\/ autorizimit: emri i p\u00ebrdoruesit - fjal\u00ebkalimi, ose client-cert\/client-key. P\u00ebr t\u00eb realizuar mund\u00ebsin\u00eb e konfigurimit t\u00eb qasjes me tokenin bearer (standard de facto p\u00ebr k8s), duhej t\u00eb b\u00ebhej pak \"kimistrie\".<\/p>\n<p>P\u00ebr zgjidhjen e k\u00ebsaj \u00e7\u00ebshtjeje mund t\u00eb p\u00ebrdorim mekanizmin e integruar t\u00eb Grafana \"Plugin Routes\" (m\u00eb shum\u00eb n\u00eb <noindex><a rel=\"nofollow\" href=\"https:\/\/grafana.com\/docs\/plugins\/developing\/auth-for-datasources\/\">faqen zyrtare t\u00eb dokumentacionit<\/a><\/noindex>). N\u00eb cil\u00ebsimet e datasource-it ton\u00eb mund t\u00eb shpallim nj\u00eb grup rregullash rruge, t\u00eb cilat do t\u00eb p\u00ebrpunohen nga serveri proxy i grafana. P\u00ebr shembull, p\u00ebr \u00e7do endpoint t\u00eb ve\u00e7ant\u00eb ekziston mund\u00ebsia e vendosjes s\u00eb kokave ose url me mund\u00ebsin\u00eb e templating, t\u00eb dh\u00ebnat p\u00ebr t\u00eb cilat mund t\u00eb merren nga fushat jsonData dhe secureJsonData (p\u00ebr ruajtjen e fjal\u00ebkalimeve ose tokeneve n\u00eb form\u00eb t\u00eb shkruar). N\u00eb shembullin ton\u00eb, k\u00ebrkesat si <i>\/__proxy\/api\/v1\/namespaces<\/i> do t\u00eb proksohen n\u00eb url si<br \/>\n\/api\/v1\/namespaces me vendosjen e kok\u00ebs Authorization: Bearer.<\/p>\n<p><img decoding=\"async\" alt=\"Zhvillimi i nj\u00eb plugin-i p\u00ebr Grafana: historia e m\u00ebsimeve t\u00eb marra\" src=\"\/wp-content\/uploads\/2019\/11\/ca73ff0fef62fba3edab7907c83639b6.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\n<img decoding=\"async\" alt=\"Zhvillimi i nj\u00eb plugin-i p\u00ebr Grafana: historia e m\u00ebsimeve t\u00eb marra\" src=\"\/wp-content\/uploads\/2019\/11\/9dab7537d7ccba90c9fb62dfa70b9fe2.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\nNatyrisht, p\u00ebr t\u00eb punuar me serverin api t\u00eb k8s, na nevojitet nj\u00eb p\u00ebrdorues me akses vet\u00ebm p\u00ebr lexim, manifestet p\u00ebr krijimin e t\u00eb cilit mund t'i gjeni gjithashtu n\u00eb <noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/devopsprodigy\/kubegraf\/tree\/master\/kubernetes\/\">kodin burimor t\u00eb plugin-it<\/a><\/noindex>.<\/p>\n<h4>Pjesa 5: lansohet<\/h4>\n<p>\n<img decoding=\"async\" alt=\"Zhvillimi i nj\u00eb plugin-i p\u00ebr Grafana: historia e m\u00ebsimeve t\u00eb marra\" src=\"\/wp-content\/uploads\/2019\/11\/3991a5d412f362770157fc567bb8009c.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\nPasi t\u00eb shkruani plugin-in tuaj p\u00ebr Grafana, natyrisht do t\u00eb d\u00ebshironit ta publikoni at\u00eb n\u00eb m\u00ebnyr\u00eb t\u00eb hapur. N\u00eb Grafana ka nj\u00eb bibliotek\u00eb plugins q\u00eb \u00ebsht\u00eb e aksesueshme n\u00eb lidhjen <noindex><a rel=\"nofollow\" href=\"https:\/\/grafana.com\/grafana\/plugins\">grafana.com\/grafana\/plugins<\/a><\/noindex> <\/p>\n<p>P\u00ebr ta b\u00ebr\u00eb plugin-in tuaj t\u00eb aksesuesh\u00ebm n\u00eb dyqanin zyrtar, duhet t\u00eb b\u00ebni PR n\u00eb <noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/grafana\/grafana-plugin-repository\">k\u00ebt\u00eb depo<\/a><\/noindex>, duke shtuar n\u00eb skedarin repo.json p\u00ebrmbajtjen si kjo:<\/p>\n<p><img decoding=\"async\" alt=\"Zhvillimi i nj\u00eb plugin-i p\u00ebr Grafana: historia e m\u00ebsimeve t\u00eb marra\" src=\"\/wp-content\/uploads\/2019\/11\/160650bf37f8f2f3e12ef7dd291e90eb.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\nku version \u2014 \u00ebsht\u00eb versioni i plugin-it tuaj, url \u2014 lidhja p\u00ebr depo, dhe commit \u2014 hash i commit-it, me t\u00eb cilin do t\u00eb jet\u00eb e aksesueshme versioni specifike e plugin-it. <\/p>\n<p>Dhe n\u00eb fund do t\u00eb shihni nj\u00eb pamje t\u00eb mrekullueshme si kjo:<\/p>\n<p><img decoding=\"async\" alt=\"Zhvillimi i nj\u00eb plugin-i p\u00ebr Grafana: historia e m\u00ebsimeve t\u00eb marra\" src=\"\/wp-content\/uploads\/2019\/11\/ff906396596e9c4c15c59f8d53555f52.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\nT\u00eb dh\u00ebnat p\u00ebr t\u00eb do t\u00eb dihen automatikisht nga Readme.md, Changelog.md dhe skedari plugin.json q\u00eb p\u00ebrshkruan plugin-in.<\/p>\n<h4>Pjesa 6: n\u00eb vend t\u00eb p\u00ebrfundimeve<\/h4>\n<p>\nNe e kemi ndaluar zhvillimin e plugin-it ton\u00eb pas lan\u00e7imit. Aktualisht po punojm\u00eb p\u00ebr monitorimin e sakt\u00eb t\u00eb p\u00ebrdorimit t\u00eb burimeve t\u00eb nyjave t\u00eb klasterit, implementimin e ve\u00e7orive t\u00eb reja p\u00ebr t\u00eb p\u00ebrmir\u00ebsuar p\u00ebrvoj\u00ebn e p\u00ebrdoruesit, si dhe po shqyrtojm\u00eb nj\u00eb sasi t\u00eb madhe t\u00eb reagimeve q\u00eb kemi marr\u00eb pas instalimeve t\u00eb plugin-it nga klient\u00ebt tan\u00eb, si dhe nga \u00e7\u00ebshtjet e raportuara n\u00eb GitHub (n\u00ebse lini nj\u00eb \u00e7\u00ebshtje ose nj\u00eb k\u00ebrkes\u00eb t\u00ebrheqjeje, do t\u00eb isha shum\u00eb i lumtur \ud83d\ude42 ).<\/p>\n<p>Shpresojm\u00eb q\u00eb ky artikull t'ju ndihmoj\u00eb t\u00eb kuptoni nj\u00eb mjet kaq t\u00eb mrekulluesh\u00ebm si Grafana dhe, ndoshta, t\u00eb shkruani plugin-in tuaj t\u00eb vet. <\/p>\n<p>Faleminderit!)<br \/>\n<br \/>Burimi: <a content=\"nofollow\" rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/company\/itsumma\/blog\/474500\/\">habr.com<\/a><\/p>","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"excerpt":{"rendered":"<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442! \u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0441\u044f\u0446\u0435\u0432 \u043d\u0430\u0437\u0430\u0434 \u043c\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b\u0438 \u0432 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u043d \u043d\u0430\u0448 \u043d\u043e\u0432\u044b\u0439 open-source \u043f\u0440\u043e\u0435\u043a\u0442 \u2014 Grafana-\u043f\u043b\u0430\u0433\u0438\u043d \u0434\u043b\u044f \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 kubernetes, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0437\u0432\u0430\u043b\u0438 DevOpsProdigy KubeGraf. \u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u043b\u0430\u0433\u0438\u043d\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0432 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u043e\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u043d\u0430 GitHub. \u0410 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0432\u0430\u043c\u0438 \u0438\u0441\u0442\u043e\u0440\u0438\u0435\u0439 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b\u0438 \u043f\u043b\u0430\u0433\u0438\u043d, \u043a\u0430\u043a\u0438\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0438 \u0441 \u043a\u0430\u043a\u0438\u043c\u0438 \u043f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u043c\u0438 \u043a\u0430\u043c\u043d\u044f\u043c\u0438 [&hellip;]<\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[688],"tags":[],"class_list":["post-52343","post","type-post","status-publish","format-standard","hentry","category-administrirovanie"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.1.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442!\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Yuri Gagarin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/prohoster.info\/sq\/blog\/administrirovanie\/razrabotka-plagina-dlya-grafana-istoriya-nabityh-shishek\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.1.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"sq_AL\" \/>\n\t\t<meta property=\"og:site_name\" content=\"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"\ud83e\udd47\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043f\u043b\u0430\u0433\u0438\u043d\u0430 \u0434\u043b\u044f Grafana: \u0438\u0441\u0442\u043e\u0440\u0438\u044f \u043d\u0430\u0431\u0438\u0442\u044b\u0445 \u0448\u0438\u0448\u0435\u043a | ProHoster\" \/>\n\t\t<meta property=\"og:description\" content=\"\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442!\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/prohoster.info\/sq\/blog\/administrirovanie\/razrabotka-plagina-dlya-grafana-istoriya-nabityh-shishek\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:width\" content=\"350\" \/>\n\t\t<meta property=\"og:image:height\" content=\"350\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2019-11-05T21:00:00+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2020-02-18T11:00:02+00:00\" \/>\n\t\t<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"\ud83e\udd47 Zhvillimi i plugin-it p\u00ebr Grafana: historia e goditjeve t\u00eb p\u00ebrvoj\u00ebs | ProHoster","description":"P\u00ebrsh\u00ebndetje t\u00eb gjith\u00ebve!","canonical_url":"https:\/\/prohoster.info\/sq\/blog\/administrirovanie\/razrabotka-plagina-dlya-grafana-istoriya-nabityh-shishek","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":null,"og:locale":"sq_AL","og:site_name":"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b","og:type":"article","og:title":"\ud83e\udd47\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043f\u043b\u0430\u0433\u0438\u043d\u0430 \u0434\u043b\u044f Grafana: \u0438\u0441\u0442\u043e\u0440\u0438\u044f \u043d\u0430\u0431\u0438\u0442\u044b\u0445 \u0448\u0438\u0448\u0435\u043a | ProHoster","og:description":"\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442!","og:url":"https:\/\/prohoster.info\/sq\/blog\/administrirovanie\/razrabotka-plagina-dlya-grafana-istoriya-nabityh-shishek","og:image":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:secure_url":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:width":350,"og:image:height":350,"article:published_time":"2019-11-05T21:00:00+00:00","article:modified_time":"2020-02-18T11:00:02+00:00","article:publisher":"https:\/\/www.facebook.com\/prohoster","article:author":"https:\/\/www.facebook.com\/prohoster"},"aioseo_meta_data":{"post_id":"52343","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"seo_analyzer_scan_date":"2026-01-24 03:18:19","breadcrumb_settings":null,"limit_modified_date":false,"reviewed_by":null,"ai":null,"created":"2021-02-28 20:45:28","updated":"2026-01-24 03:18:19","focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"gt_translate_keys":[{"key":"link","format":"url"}],"_links":{"self":[{"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/posts\/52343","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/comments?post=52343"}],"version-history":[{"count":0,"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/posts\/52343\/revisions"}],"wp:attachment":[{"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/media?parent=52343"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/categories?post=52343"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prohoster.info\/sq\/wp-json\/wp\/v2\/tags?post=52343"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}