diff --git a/dist/components/clusters/nodeInfo.js b/dist/components/clusters/nodeInfo.js index f916687..15a09eb 100644 --- a/dist/components/clusters/nodeInfo.js +++ b/dist/components/clusters/nodeInfo.js @@ -61,17 +61,15 @@ System.register(['moment'], function (_export, _context) { alertSrv.set("no cluster specified.", "no cluster specified in url", 'error'); return; } else { - (function () { - var cluster_id = $location.search().cluster; - var node_name = $location.search().node; - - _this.loadDatasource(cluster_id).then(function () { - _this.clusterDS.getNode(node_name).then(function (node) { - _this.node = node; - _this.pageReady = true; - }); + var cluster_id = $location.search().cluster; + var node_name = $location.search().node; + + this.loadDatasource(cluster_id).then(function () { + _this.clusterDS.getNode(node_name).then(function (node) { + _this.node = node; + _this.pageReady = true; }); - })(); + }); } } diff --git a/dist/components/clusters/nodeInfo.js.map b/dist/components/clusters/nodeInfo.js.map index bd17752..0bc66f4 100644 --- a/dist/components/clusters/nodeInfo.js.map +++ b/dist/components/clusters/nodeInfo.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../../src/components/clusters/nodeInfo.js"],"names":["slugify","str","slug","replace","moment","NodeInfoCtrl","$scope","$injector","backendSrv","datasourceSrv","$q","$location","alertSrv","document","title","pageReady","cluster","clusterDS","node","search","set","cluster_id","node_name","loadDatasource","then","getNode","id","get","ds","name","path","jsonData","metadata","condition","status","type","value","text","conditionStatus","lastTransitionTime","format","templateUrl"],"mappings":";;;;;;;;;;;;;AA2EA,WAASA,OAAT,CAAiBC,GAAjB,EAAsB;AACpB,QAAIC,OAAOD,IAAIE,OAAJ,CAAY,GAAZ,EAAiB,IAAjB,EAAuBA,OAAvB,CAA+B,GAA/B,EAAoC,KAApC,EAA2CA,OAA3C,CAAmD,MAAnD,EAA2D,GAA3D,EAAgEA,OAAhE,CAAwE,OAAxE,EAAiF,EAAjF,CAAX;AACA,WAAOD,IAAP;AACD;;;;AA9EME,Y;;;;;;;;;;;;;;;;;;;;;8BAEMC,Y;AACX;AACA,8BAAYC,MAAZ,EAAoBC,SAApB,EAA+BC,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;;8CAEmB;AAClB,iBAAKN,SAAL,CAAemB,IAAf,CAAoB,8BAApB,EACGX,MADH,CACU;AACN,gCAAkB,KAAKH,OAAL,CAAae,QAAb,CAAsBH,EADlC;AAEN,6BAAe,KAAKZ,OAAL,CAAaa,IAFtB;AAGN,0BAAY7B,QAAQ,KAAKkB,IAAL,CAAUc,QAAV,CAAmBH,IAA3B;AAHN,aADV;AAMD;;;0CAEeI,S,EAAW;AACzB,gBAAIC,MAAJ;AACA,gBAAID,UAAUE,IAAV,KAAmB,OAAvB,EAAgC;AAC9BD,uBAASD,UAAUC,MAAV,KAAqB,MAA9B;AACD,aAFD,MAEO;AACLA,uBAASD,UAAUC,MAAV,KAAqB,OAA9B;AACD;;AAED,mBAAO;AACLE,qBAAOF,MADF;AAELG,oBAAMH,SAAS,IAAT,GAAgB;AAFjB,aAAP;AAID;;;wCAEaD,S,EAAW;AACvB,mBAAO,KAAKK,eAAL,CAAqBL,SAArB,EAAgCG,KAAvC;AACD;;;sDAE2BH,S,EAAW;AACrC,mBAAO7B,OAAO6B,UAAUM,kBAAjB,EAAqCC,MAArC,CAA4C,qBAA5C,CAAP;AACD;;;;;;;;AAQHnC,mBAAaoC,WAAb,GAA2B,6CAA3B","file":"nodeInfo.js","sourcesContent":["import moment from 'moment';\n\nexport class NodeInfoCtrl {\n /** @ngInject */\n constructor($scope, $injector, backendSrv, datasourceSrv, $q, $location, alertSrv) {\n this.$q = $q;\n this.backendSrv = backendSrv;\n this.datasourceSrv = datasourceSrv;\n this.$location = $location;\n document.title = 'Grafana Kubernetes App';\n\n this.pageReady = false;\n this.cluster = {};\n this.clusterDS = {};\n this.node = {};\n\n if (!(\"cluster\" in $location.search())) {\n alertSrv.set(\"no cluster specified.\", \"no cluster specified in url\", 'error');\n return;\n } else {\n let cluster_id = $location.search().cluster;\n let node_name = $location.search().node;\n\n this.loadDatasource(cluster_id).then(() => {\n this.clusterDS.getNode(node_name).then(node => {\n this.node = node;\n this.pageReady = true;\n });\n });\n }\n }\n\n loadDatasource(id) {\n return this.backendSrv.get('api/datasources/' + id)\n .then(ds => {\n this.cluster = ds;\n return this.datasourceSrv.get(ds.name);\n }).then(clusterDS => {\n this.clusterDS = clusterDS;\n return clusterDS;\n });\n }\n\n goToNodeDashboard() {\n this.$location.path(\"dashboard/db/kubernetes-node\")\n .search({\n \"var-datasource\": this.cluster.jsonData.ds,\n \"var-cluster\": this.cluster.name,\n \"var-node\": slugify(this.node.metadata.name)\n });\n }\n\n conditionStatus(condition) {\n var status;\n if (condition.type === \"Ready\") {\n status = condition.status === \"True\";\n } else {\n status = condition.status === \"False\";\n }\n\n return {\n value: status,\n text: status ? \"Ok\" : \"Error\"\n };\n }\n\n isConditionOk(condition) {\n return this.conditionStatus(condition).value;\n }\n\n conditionLastTransitionTime(condition) {\n return moment(condition.lastTransitionTime).format('YYYY-MM-DD HH:mm:ss');\n }\n}\n\nfunction slugify(str) {\n var slug = str.replace(\"@\", \"at\").replace(\"&\", \"and\").replace(/[.]/g, \"_\").replace(\"/\\W+/\", \"\");\n return slug;\n}\n\nNodeInfoCtrl.templateUrl = 'components/clusters/partials/node_info.html';\n"]} \ No newline at end of file +{"version":3,"sources":["../../../src/components/clusters/nodeInfo.js"],"names":["slugify","str","slug","replace","moment","NodeInfoCtrl","$scope","$injector","backendSrv","datasourceSrv","$q","$location","alertSrv","document","title","pageReady","cluster","clusterDS","node","search","set","cluster_id","node_name","loadDatasource","then","getNode","id","get","ds","name","path","jsonData","metadata","condition","status","type","value","text","conditionStatus","lastTransitionTime","format","templateUrl"],"mappings":";;;;;;;;;;;;;AA2EA,WAASA,OAAT,CAAiBC,GAAjB,EAAsB;AACpB,QAAIC,OAAOD,IAAIE,OAAJ,CAAY,GAAZ,EAAiB,IAAjB,EAAuBA,OAAvB,CAA+B,GAA/B,EAAoC,KAApC,EAA2CA,OAA3C,CAAmD,MAAnD,EAA2D,GAA3D,EAAgEA,OAAhE,CAAwE,OAAxE,EAAiF,EAAjF,CAAX;AACA,WA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FL,IAJE,CAIG,qBAAa;AACnB,qBAAKP,SAAL,GAAiBA,SAAjB;AACA,qBAAOA,SAAP;AACD,aAPI,CAAP;AAQD;;;8CAEmB;AAClB,iBAAKN,SAAL,CAAemB,IAAf,CAAoB,8BAApB,EACGX,MADH,CACU;AACN,gCAAkB,KAAKH,OAAL,CAAae,QAAb,CAAsBH,EADlC;AAEN,6BAAe,KAAKZ,OAAL,CAAaa,IAFtB;AAGN,0BAAY7B,QAAQ,KAAKkB,IAAL,CAAUc,QAAV,CAAmBH,IAA3B;AAHN,aADV;AAMD;;;0CAEeI,S,EAAW;AACzB,gBAAIC,MAAJ;AACA,gBAAID,UAAUE,IAAV,KAAmB,OAAvB,EAAgC;AAC9BD,uBAASD,UAAUC,MAAV,KAAqB,MAA9B;AACD,aAFD,MAEO;AACLA,uBAASD,UAAUC,MAAV,KAAqB,OAA9B;AACD;;AAED,mBAAO;AACLE,qBAAOF,MADF;AAELG,oBAAMH,SAAS,IAAT,GAAgB;AAFjB,aAAP;AAID;;;wCAEaD,S,EAAW;AACvB,mBAAO,KAAKK,eAAL,CAAqBL,SAArB,EAAgCG,KAAvC;AACD;;;sDAE2BH,S,EAAW;AACrC,mBAAO7B,OAAO6B,UAAUM,kBAAjB,EAAqCC,MAArC,CAA4C,qBAA5C,CAAP;AACD;;;;;;;;AAQHnC,mBAAaoC,WAAb,GAA2B,6CAA3B","file":"nodeInfo.js","sourcesContent":["import moment from 'moment';\n\nexport class NodeInfoCtrl {\n /** @ngInject */\n constructor($scope, $injector, backendSrv, datasourceSrv, $q, $location, alertSrv) {\n this.$q = $q;\n this.backendSrv = backendSrv;\n this.datasourceSrv = datasourceSrv;\n this.$location = $location;\n document.title = 'Grafana Kubernetes App';\n\n this.pageReady = false;\n this.cluster = {};\n this.clusterDS = {};\n this.node = {};\n\n if (!(\"cluster\" in $location.search())) {\n alertSrv.set(\"no cluster specified.\", \"no cluster specified in url\", 'error');\n return;\n } else {\n let cluster_id = $location.search().cluster;\n let node_name = $location.search().node;\n\n this.loadDatasource(cluster_id).then(() => {\n this.clusterDS.getNode(node_name).then(node => {\n this.node = node;\n this.pageReady = true;\n });\n });\n }\n }\n\n loadDatasource(id) {\n return this.backendSrv.get('api/datasources/' + id)\n .then(ds => {\n this.cluster = ds;\n return this.datasourceSrv.get(ds.name);\n }).then(clusterDS => {\n this.clusterDS = clusterDS;\n return clusterDS;\n });\n }\n\n goToNodeDashboard() {\n this.$location.path(\"dashboard/db/kubernetes-node\")\n .search({\n \"var-datasource\": this.cluster.jsonData.ds,\n \"var-cluster\": this.cluster.name,\n \"var-node\": slugify(this.node.metadata.name)\n });\n }\n\n conditionStatus(condition) {\n var status;\n if (condition.type === \"Ready\") {\n status = condition.status === \"True\";\n } else {\n status = condition.status === \"False\";\n }\n\n return {\n value: status,\n text: status ? \"Ok\" : \"Error\"\n };\n }\n\n isConditionOk(condition) {\n return this.conditionStatus(condition).value;\n }\n\n conditionLastTransitionTime(condition) {\n return moment(condition.lastTransitionTime).format('YYYY-MM-DD HH:mm:ss');\n }\n}\n\nfunction slugify(str) {\n var slug = str.replace(\"@\", \"at\").replace(\"&\", \"and\").replace(/[.]/g, \"_\").replace(\"/\\W+/\", \"\");\n return slug;\n}\n\nNodeInfoCtrl.templateUrl = 'components/clusters/partials/node_info.html';\n"]} \ No newline at end of file diff --git a/dist/components/clusters/podInfo.js b/dist/components/clusters/podInfo.js index 1b5308f..13dce14 100644 --- a/dist/components/clusters/podInfo.js +++ b/dist/components/clusters/podInfo.js @@ -58,17 +58,15 @@ System.register(["moment"], function (_export, _context) { alertSrv.set("no cluster specified.", "no cluster specified in url", 'error'); return; } else { - (function () { - _this.cluster_id = $location.search().cluster; - var pod_name = $location.search().pod; - - _this.loadDatasource(_this.cluster_id).then(function () { - _this.clusterDS.getPod(pod_name).then(function (pod) { - _this.pod = pod; - _this.pageReady = true; - }); + this.cluster_id = $location.search().cluster; + var pod_name = $location.search().pod; + + this.loadDatasource(this.cluster_id).then(function () { + _this.clusterDS.getPod(pod_name).then(function (pod) { + _this.pod = pod; + _this.pageReady = true; }); - })(); + }); } } diff --git a/dist/components/clusters/podInfo.js.map b/dist/components/clusters/podInfo.js.map index 44b59fa..9900b93 100644 --- a/dist/components/clusters/podInfo.js.map +++ b/dist/components/clusters/podInfo.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../../src/components/clusters/podInfo.js"],"names":["slugify","str","slug","replace","moment","PodInfoCtrl","$scope","$injector","backendSrv","datasourceSrv","$q","$location","alertSrv","document","title","pageReady","pod","search","set","cluster_id","cluster","pod_name","loadDatasource","then","clusterDS","getPod","id","get","datasource","ds","jsonData","name","condition","status","type","value","text","path","spec","nodeName","metadata","namespace","conditionStatus","time","format","templateUrl"],"mappings":";;;;;;;;;;;;;AAEA,WAASA,OAAT,CAAiBC,GAAjB,EAAsB;AACpB,QAAIC,OAAOD,IAAIE,OAAJ,CAAY,GAAZ,EAAiB,IAAjB,EAAuBA,OAAvB,CAA+B,GAA/B,EAAoC,KAApC,EAA2CA,OAA3C,CAAmD,MAAnD,EAA2D,GAA3D,EAAgEA,OAAhE,CAAwE,OAAxE,EAAiF,EAAjF,CAAX;AACA,WAAOD,IAAP;AACD;;;;AALME,Y;;;;;;;;;;;;;;;;;;;;;6BAOMC,W;AACX;AACA,6BAAYC,MAAZ,EAAoBC,SAApB,EAA+BC,UAA/B,EAA2CC,aAA3C,EAA0DC,EAA1D,EAA8DC,SAA9D,EAAyEC,QAAzE,EAAmF;AAAA;;AAAA;;AACjF,eAAKF,EAAL,GAAUA,EAAV;AACA,eAAKF,UAAL,GAAkBA,UAAlB;AACA,eAAKC,aAAL,GAAqBA,aAArB;AACA,eAAKE,SAAL,GAAiBA,SAAjB;AACAE,mBAASC,KAAT,GAAiB,wBAAjB;;AAEA,eAAKC,SAAL,GAAiB,KAAjB;AACA,eAAKC,GAAL,GAAW,EAAX;AACA,cAAI,EAAE,aAAaL,UAAUM,MAAV,EAAf,CAAJ,EAAwC;AACtCL,qBAASM,GAAT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AGN,0BAAY/B,QAAQgB,IAAIsB,IAAJ,CAASC,QAAjB,CAHN;AAIN,+BAAiBvB,IAAIwB,QAAJ,CAAaC,SAJxB;AAKN,yBAAWzB,IAAIwB,QAAJ,CAAaT;AALlB,aADR;AAQD;;;wCAEaC,S,EAAW;AACvB,mBAAO,KAAKU,eAAL,CAAqBV,SAArB,EAAgCG,KAAvC;AACD;;;qCAEUQ,I,EAAM;AACf,mBAAOvC,OAAOuC,IAAP,EAAaC,MAAb,CAAoB,qBAApB,CAAP;AACD;;;;;;;;AAGHvC,kBAAYwC,WAAZ,GAA0B,4CAA1B","file":"podInfo.js","sourcesContent":["import moment from 'moment';\n\nfunction slugify(str) {\n var slug = str.replace(\"@\", \"at\").replace(\"&\", \"and\").replace(/[.]/g, \"_\").replace(\"/\\W+/\", \"\");\n return slug;\n}\n\nexport class PodInfoCtrl {\n /** @ngInject */\n constructor($scope, $injector, backendSrv, datasourceSrv, $q, $location, alertSrv) {\n this.$q = $q;\n this.backendSrv = backendSrv;\n this.datasourceSrv = datasourceSrv;\n this.$location = $location;\n document.title = 'Grafana Kubernetes App';\n\n this.pageReady = false;\n this.pod = {};\n if (!(\"cluster\" in $location.search())) {\n alertSrv.set(\"no cluster specified.\", \"no cluster specified in url\", 'error');\n return;\n } else {\n this.cluster_id = $location.search().cluster;\n let pod_name = $location.search().pod;\n\n this.loadDatasource(this.cluster_id).then(() => {\n this.clusterDS.getPod(pod_name).then(pod => {\n this.pod = pod;\n this.pageReady = true;\n });\n });\n }\n }\n\n loadDatasource(id) {\n return this.backendSrv.get('api/datasources/' + id)\n .then(ds => {\n this.datasource = ds.jsonData.ds;\n return this.datasourceSrv.get(ds.name);\n }).then(clusterDS => {\n this.clusterDS = clusterDS;\n return clusterDS;\n });\n }\n\n conditionStatus(condition) {\n var status;\n if (condition.type === \"Ready\") {\n status = condition.status === \"True\";\n } else {\n status = condition.status === \"False\";\n }\n\n return {\n value: status,\n text: status ? \"Ok\" : \"Error\"\n };\n }\n\n goToPodDashboard(pod) {\n this.$location.path(\"dashboard/db/kubernetes-container\")\n .search({\n \"var-datasource\": this.datasource,\n \"var-cluster\": this.clusterDS.name,\n \"var-node\": slugify(pod.spec.nodeName),\n \"var-namespace\": pod.metadata.namespace,\n \"var-pod\": pod.metadata.name\n });\n }\n\n isConditionOk(condition) {\n return this.conditionStatus(condition).value;\n }\n\n formatTime(time) {\n return moment(time).format('YYYY-MM-DD HH:mm:ss');\n }\n}\n\nPodInfoCtrl.templateUrl = 'components/clusters/partials/pod_info.html';\n"]} \ No newline at end of file +{"version":3,"sources":["../../../src/components/clusters/podInfo.js"],"names":["slugify","str","slug","replace","moment","PodInfoCtrl","$scope","$injector","backendSrv","datasourceSrv","$q","$location","alertSrv","document","title","pageReady","pod","search","set","cluster_id","cluster","pod_name","loadDatasource","then","clusterDS","getPod","id","get","datasource","ds","jsonData","name","condition","status","type","value","text","path","spec","nodeName","metadata","namespace","conditionStatus","time","format","templateUrl"],"mappings":";;;;;;;;;;;;;AAEA,WAASA,OAAT,CAAiBC,GAAjB,EAAsB;AACpB,QAAIC,OAAOD,IAAIE,OAAJ,CAAY,GAAZ,EAAiB,IAAjB,EAAuBA,OAAvB,CAA+B,GAA/B,EAAoC,KAApC,EAA2CA,OAA3C,CAAmD,MAAnD,EAA2D,GAA3D,EAAgEA,OAAhE,CAAwE,OAAxE,EAAiF,EAAjF,CAAX;AACA,WAAOD,IAAP;AACD;;;;AALME,Y;;;;;;;;;;;;;;;;;;;;;6BAOMC,W;AACX;AACA,6BAAYC,MAAZ,EAAoBC,SAApB,EAA+BC,UAA/B,EAA2CC,aAA3C,EAA0DC,EAA1D,EAA8DC,SAA9D,EAAyEC,QAAzE,EAAmF;AAAA;;AAAA;;AACjF,eAAKF,EAAL,GAAUA,EAAV;AACA,eAAKF,UAAL,GAAkBA,UAAlB;AACA,eAAKC,aAAL,GAAqBA,aAArB;AACA,eAAKE,SAAL,GAAiBA,SAAjB;AACAE,mBAASC,KAAT,GAAiB,w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ACpB,iBAAKL,SAAL,CAAe0B,IAAf,CAAoB,mCAApB,EACCpB,MADD,CACQ;AACN,gCAAkB,KAAKW,UADjB;AAEN,6BAAe,KAAKJ,SAAL,CAAeO,IAFxB;AAGN,0BAAY/B,QAAQgB,IAAIsB,IAAJ,CAASC,QAAjB,CAHN;AAIN,+BAAiBvB,IAAIwB,QAAJ,CAAaC,SAJxB;AAKN,yBAAWzB,IAAIwB,QAAJ,CAAaT;AALlB,aADR;AAQD;;;wCAEaC,S,EAAW;AACvB,mBAAO,KAAKU,eAAL,CAAqBV,SAArB,EAAgCG,KAAvC;AACD;;;qCAEUQ,I,EAAM;AACf,mBAAOvC,OAAOuC,IAAP,EAAaC,MAAb,CAAoB,qBAApB,CAAP;AACD;;;;;;;;AAGHvC,kBAAYwC,WAAZ,GAA0B,4CAA1B","file":"podInfo.js","sourcesContent":["import moment from 'moment';\n\nfunction slugify(str) {\n var slug = str.replace(\"@\", \"at\").replace(\"&\", \"and\").replace(/[.]/g, \"_\").replace(\"/\\W+/\", \"\");\n return slug;\n}\n\nexport class PodInfoCtrl {\n /** @ngInject */\n constructor($scope, $injector, backendSrv, datasourceSrv, $q, $location, alertSrv) {\n this.$q = $q;\n this.backendSrv = backendSrv;\n this.datasourceSrv = datasourceSrv;\n this.$location = $location;\n document.title = 'Grafana Kubernetes App';\n\n this.pageReady = false;\n this.pod = {};\n if (!(\"cluster\" in $location.search())) {\n alertSrv.set(\"no cluster specified.\", \"no cluster specified in url\", 'error');\n return;\n } else {\n this.cluster_id = $location.search().cluster;\n let pod_name = $location.search().pod;\n\n this.loadDatasource(this.cluster_id).then(() => {\n this.clusterDS.getPod(pod_name).then(pod => {\n this.pod = pod;\n this.pageReady = true;\n });\n });\n }\n }\n\n loadDatasource(id) {\n return this.backendSrv.get('api/datasources/' + id)\n .then(ds => {\n this.datasource = ds.jsonData.ds;\n return this.datasourceSrv.get(ds.name);\n }).then(clusterDS => {\n this.clusterDS = clusterDS;\n return clusterDS;\n });\n }\n\n conditionStatus(condition) {\n var status;\n if (condition.type === \"Ready\") {\n status = condition.status === \"True\";\n } else {\n status = condition.status === \"False\";\n }\n\n return {\n value: status,\n text: status ? \"Ok\" : \"Error\"\n };\n }\n\n goToPodDashboard(pod) {\n this.$location.path(\"dashboard/db/kubernetes-container\")\n .search({\n \"var-datasource\": this.datasource,\n \"var-cluster\": this.clusterDS.name,\n \"var-node\": slugify(pod.spec.nodeName),\n \"var-namespace\": pod.metadata.namespace,\n \"var-pod\": pod.metadata.name\n });\n }\n\n isConditionOk(condition) {\n return this.conditionStatus(condition).value;\n }\n\n formatTime(time) {\n return moment(time).format('YYYY-MM-DD HH:mm:ss');\n }\n}\n\nPodInfoCtrl.templateUrl = 'components/clusters/partials/pod_info.html';\n"]} \ No newline at end of file diff --git a/dist/panels/nodeData/nodeData.js b/dist/panels/nodeData/nodeData.js index ae2bc4e..5f7206f 100644 --- a/dist/panels/nodeData/nodeData.js +++ b/dist/panels/nodeData/nodeData.js @@ -119,34 +119,32 @@ System.register(['moment', 'app/plugins/sdk', 'lodash', './nodeStats'], function this.alertSrv.set("no cluster specified.", "no cluster specified in url", 'error'); return; } else { - (function () { - var cluster_id = cluster.current.value; - var nodeVar = _.find(_this2.templateVariables, { 'name': 'node' }); - var node_name = nodeVar.current.value !== '$__all' ? nodeVar.current.value : 'All'; - var graphiteDs = _.find(_this2.templateVariables, { 'name': 'datasource' }).current.value; + var cluster_id = cluster.current.value; + var nodeVar = _.find(this.templateVariables, { 'name': 'node' }); + var node_name = nodeVar.current.value !== '$__all' ? nodeVar.current.value : 'All'; + var graphiteDs = _.find(this.templateVariables, { 'name': 'datasource' }).current.value; - _this2.loadDatasource(cluster_id).then(function () { - return _this2.nodeStatsDatasource.getNodeStats(cluster_id, graphiteDs); - }).then(function (nodeStats) { - if (node_name === 'All') { - _this2.isInListMode = true; - _this2.clusterDS.getNodes().then(function (nodes) { - _this2.nodes = _.map(nodes, function (node) { - node.healthState = _this2.getNodeHealth(node); - _this2.nodeStatsDatasource.updateNodeWithStats(node, nodeStats); + this.loadDatasource(cluster_id).then(function () { + return _this2.nodeStatsDatasource.getNodeStats(cluster_id, graphiteDs); + }).then(function (nodeStats) { + if (node_name === 'All') { + _this2.isInListMode = true; + _this2.clusterDS.getNodes().then(function (nodes) { + _this2.nodes = _.map(nodes, function (node) { + node.healthState = _this2.getNodeHealth(node); + _this2.nodeStatsDatasource.updateNodeWithStats(node, nodeStats); - return node; - }); + return node; }); - } else { - _this2.isInListMode = false; - _this2.clusterDS.getNode(unslugify(node_name)).then(function (node) { - _this2.node = node; - _this2.pageReady = true; - }); - } - }); - })(); + }); + } else { + _this2.isInListMode = false; + _this2.clusterDS.getNode(unslugify(node_name)).then(function (node) { + _this2.node = node; + _this2.pageReady = true; + }); + } + }); } } }, { diff --git a/dist/panels/nodeData/nodeData.js.map b/dist/panels/nodeData/nodeData.js.map index 6ecdcb7..e0c0636 100644 --- a/dist/panels/nodeData/nodeData.js.map +++ b/dist/panels/nodeData/nodeData.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../../src/panels/nodeData/nodeData.js"],"names":["slugify","str","slug","replace","unslugify","moment","PanelCtrl","_","NodeStatsDatasource","panelDefaults","NodeDataCtrl","$scope","$injector","backendSrv","datasourceSrv","$location","alertSrv","timeSrv","variableSrv","defaults","panel","templateVariables","variables","nodeStatsDatasource","document","title","pageReady","cluster","clusterDS","node","isInListMode","nodes","loadCluster","find","set","cluster_id","current","value","nodeVar","node_name","graphiteDs","loadDatasource","then","getNodeStats","getNodes","map","healthState","getNodeHealth","updateNodeWithStats","nodeStats","getNode","health","message","forEach","status","conditions","condition","type","getHealthState","text","iconClass","stateClass","id","get","filter","result","ds","name","variable","metadata","variableUpdated","$emit","$root","$broadcast","conditionStatus","lastTransitionTime","format","templateUrl"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwKA,WAASA,OAAT,CAAiBC,GAAjB,EAAsB;AACpB,QAAIC,OAAOD,IAAIE,O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;AACA,gBAAIE,UAAUC,IAAV,KAAmB,OAAvB,EAAgC;AAC9BH,uBAASE,UAAUF,MAAV,KAAqB,MAA9B;AACD,aAFD,MAEO;AACLA,uBAASE,UAAUF,MAAV,KAAqB,OAA9B;AACD;;AAED,mBAAO;AACLjB,qBAAOiB,MADF;AAELK,oBAAML,SAAS,IAAT,GAAgB;AAFjB,aAAP;AAID;;;wCAEaE,S,EAAW;AACvB,mBAAO,KAAKkB,eAAL,CAAqBlB,SAArB,EAAgCnB,KAAvC;AACD;;;sDAE2BmB,S,EAAW;AACrC,mBAAOnD,OAAOmD,UAAUmB,kBAAjB,EAAqCC,MAArC,CAA4C,qBAA5C,CAAP;AACD;;;;QA7J+BtE,S;;;;AA0KlCI,mBAAamE,WAAb,GAA2B,yCAA3B","file":"nodeData.js","sourcesContent":["import moment from 'moment';\nimport {PanelCtrl} from 'app/plugins/sdk';\nimport _ from 'lodash';\nimport NodeStatsDatasource from './nodeStats';\n\nconst panelDefaults = {\n};\n\nexport class NodeDataCtrl extends PanelCtrl {\n /** @ngInject */\n constructor($scope, $injector, backendSrv, datasourceSrv, $location, alertSrv, timeSrv, variableSrv) {\n super($scope, $injector);\n _.defaults(this.panel, panelDefaults);\n\n this.backendSrv = backendSrv;\n this.datasourceSrv = datasourceSrv;\n this.$location = $location;\n this.alertSrv = alertSrv;\n this.timeSrv = timeSrv;\n this.variableSrv = variableSrv;\n this.templateVariables = this.variableSrv.variables;\n this.nodeStatsDatasource = new NodeStatsDatasource(datasourceSrv, timeSrv);\n document.title = 'Grafana Kubernetes App';\n\n this.pageReady = false;\n this.cluster = {};\n this.clusterDS = {};\n this.node = {};\n\n this.isInListMode = false;\n this.nodes = [];\n\n this.loadCluster();\n }\n\n loadCluster() {\n const cluster = _.find(this.templateVariables, {'name': 'cluster'});\n if (!cluster) {\n this.alertSrv.set(\"no cluster specified.\", \"no cluster specified in url\", 'error');\n return;\n } else {\n const cluster_id = cluster.current.value;\n const nodeVar = _.find(this.templateVariables, {'name': 'node'});\n const node_name = nodeVar.current.value !== '$__all' ? nodeVar.current.value : 'All';\n const graphiteDs = _.find(this.templateVariables, {'name': 'datasource'}).current.value;\n\n this.loadDatasource(cluster_id).then(() => {\n return this.nodeStatsDatasource.getNodeStats(cluster_id, graphiteDs);\n }).then(nodeStats => {\n if (node_name === 'All') {\n this.isInListMode = true;\n this.clusterDS.getNodes().then(nodes => {\n this.nodes = _.map(nodes, node => {\n node.healthState = this.getNodeHealth(node);\n this.nodeStatsDatasource.updateNodeWithStats(node, nodeStats);\n\n return node;\n });\n });\n } else {\n this.isInListMode = false;\n this.clusterDS.getNode(unslugify(node_name)).then(node => {\n this.node = node;\n this.pageReady = true;\n });\n }\n });\n }\n }\n\n getNodeHealth(node) {\n let health = \"unhealthy\";\n let message = '';\n _.forEach(node.status.conditions, condition => {\n if (condition.type === \"Ready\" &&\n condition.status === \"True\") {\n health = \"ok\";\n } else {\n message = condition.message;\n }\n });\n return this.getHealthState(health, message);\n }\n\n getHealthState(health, message) {\n switch (health) {\n case 'ok': {\n return {\n text: 'OK',\n iconClass: 'icon-gf icon-gf-online',\n stateClass: 'alert-state-ok'\n };\n }\n case 'unhealthy': {\n return {\n text: 'UNHEALTHY',\n iconClass: 'icon-gf icon-gf-critical',\n stateClass: 'alert-state-critical',\n message: message || ''\n };\n }\n case 'warning': {\n return {\n text: 'warning',\n iconClass: \"icon-gf icon-gf-critical\",\n stateClass: 'alert-state-warning',\n message: message || ''\n };\n }\n }\n }\n\n refresh() {\n this.loadCluster();\n }\n\n loadDatasource(id) {\n return this.backendSrv.get('api/datasources')\n .then(result => {\n return _.filter(result, {\"type\": \"raintank-kubernetes-datasource\", \"name\": id})[0];\n })\n .then(ds => {\n if (!ds) {\n this.alertSrv.set(\"Failed to connect\", \"Could not connect to the specified cluster.\", 'error');\n throw \"Failed to connect to \" + id;\n }\n this.cluster = ds;\n return this.datasourceSrv.get(ds.name);\n }).then(clusterDS => {\n this.clusterDS = clusterDS;\n return clusterDS;\n });\n }\n\n goToNodeDashboard(node) {\n const variable = _.find(this.templateVariables, {'name': 'node'});\n variable.current.text = node === 'All' ? 'All': slugify(node.metadata.name);\n variable.current.value = node === 'All' ? '$__all': slugify(node.metadata.name);\n\n this.variableSrv.variableUpdated(variable).then(() => {\n this.$scope.$emit('template-variable-value-updated');\n this.$scope.$root.$broadcast('refresh');\n });\n }\n\n conditionStatus(condition) {\n var status;\n if (condition.type === \"Ready\") {\n status = condition.status === \"True\";\n } else {\n status = condition.status === \"False\";\n }\n\n return {\n value: status,\n text: status ? \"Ok\" : \"Error\"\n };\n }\n\n isConditionOk(condition) {\n return this.conditionStatus(condition).value;\n }\n\n conditionLastTransitionTime(condition) {\n return moment(condition.lastTransitionTime).format('YYYY-MM-DD HH:mm:ss');\n }\n}\n\nfunction slugify(str) {\n var slug = str.replace(\"@\", \"at\").replace(\"&\", \"and\").replace(/[.]/g, \"_\").replace(\"/\\W+/\", \"\");\n return slug;\n}\n\nfunction unslugify(str) {\n var slug = str.replace(/[_]/g, \".\");\n return slug;\n}\n\nNodeDataCtrl.templateUrl = 'panels/nodeData/partials/node_info.html';\n"]} \ No newline at end of file +{"version":3,"sources":["../../../src/panels/nodeData/nodeData.js"],"names":["slugify","str","slug","replace","unslugify","moment","PanelCtrl","_","NodeStatsDatasource","panelDefaults","NodeDataCtrl","$scope","$injector","backendSrv","datasourceSrv","$location","alertSrv","timeSrv","variableSrv","defaults","panel","templateVariables","variables","nodeStatsDatasource","document","title","pageReady","cluster","clusterDS","node","isInListMode","nodes","loadCluster","find","set","cluster_id","current","value","nodeVar","node_name","graphiteDs","loadDatasource","then","getNodeStats","getNodes","map","healthState","getNodeHealth","updateNodeWithStats","nodeStats","getNode","health","message","forEach","status","conditions","condition","type","getHealthState","text","iconClass","stateClass","id","get","filter","result","ds","name","variable","metadata","variableUpdated","$emit","$root","$broadcast","conditionStatus","lastTransitionTime","format","templateUrl"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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A7B;AACD,aAHD;AAID;;;0CAEejB,S,EAAW;AACzB,gBAAIF,MAAJ;AACA,gBAAIE,UAAUC,IAAV,KAAmB,OAAvB,EAAgC;AAC9BH,uBAASE,UAAUF,MAAV,KAAqB,MAA9B;AACD,aAFD,MAEO;AACLA,uBAASE,UAAUF,MAAV,KAAqB,OAA9B;AACD;;AAED,mBAAO;AACLjB,qBAAOiB,MADF;AAELK,oBAAML,SAAS,IAAT,GAAgB;AAFjB,aAAP;AAID;;;wCAEaE,S,EAAW;AACvB,mBAAO,KAAKkB,eAAL,CAAqBlB,SAArB,EAAgCnB,KAAvC;AACD;;;sDAE2BmB,S,EAAW;AACrC,mBAAOnD,OAAOmD,UAAUmB,kBAAjB,EAAqCC,MAArC,CAA4C,qBAA5C,CAAP;AACD;;;;QA7J+BtE,S;;;;AA0KlCI,mBAAamE,WAAb,GAA2B,yCAA3B","file":"nodeData.js","sourcesContent":["import moment from 'moment';\nimport {PanelCtrl} from 'app/plugins/sdk';\nimport _ from 'lodash';\nimport NodeStatsDatasource from './nodeStats';\n\nconst panelDefaults = {\n};\n\nexport class NodeDataCtrl extends PanelCtrl {\n /** @ngInject */\n constructor($scope, $injector, backendSrv, datasourceSrv, $location, alertSrv, timeSrv, variableSrv) {\n super($scope, $injector);\n _.defaults(this.panel, panelDefaults);\n\n this.backendSrv = backendSrv;\n this.datasourceSrv = datasourceSrv;\n this.$location = $location;\n this.alertSrv = alertSrv;\n this.timeSrv = timeSrv;\n this.variableSrv = variableSrv;\n this.templateVariables = this.variableSrv.variables;\n this.nodeStatsDatasource = new NodeStatsDatasource(datasourceSrv, timeSrv);\n document.title = 'Grafana Kubernetes App';\n\n this.pageReady = false;\n this.cluster = {};\n this.clusterDS = {};\n this.node = {};\n\n this.isInListMode = false;\n this.nodes = [];\n\n this.loadCluster();\n }\n\n loadCluster() {\n const cluster = _.find(this.templateVariables, {'name': 'cluster'});\n if (!cluster) {\n this.alertSrv.set(\"no cluster specified.\", \"no cluster specified in url\", 'error');\n return;\n } else {\n const cluster_id = cluster.current.value;\n const nodeVar = _.find(this.templateVariables, {'name': 'node'});\n const node_name = nodeVar.current.value !== '$__all' ? nodeVar.current.value : 'All';\n const graphiteDs = _.find(this.templateVariables, {'name': 'datasource'}).current.value;\n\n this.loadDatasource(cluster_id).then(() => {\n return this.nodeStatsDatasource.getNodeStats(cluster_id, graphiteDs);\n }).then(nodeStats => {\n if (node_name === 'All') {\n this.isInListMode = true;\n this.clusterDS.getNodes().then(nodes => {\n this.nodes = _.map(nodes, node => {\n node.healthState = this.getNodeHealth(node);\n this.nodeStatsDatasource.updateNodeWithStats(node, nodeStats);\n\n return node;\n });\n });\n } else {\n this.isInListMode = false;\n this.clusterDS.getNode(unslugify(node_name)).then(node => {\n this.node = node;\n this.pageReady = true;\n });\n }\n });\n }\n }\n\n getNodeHealth(node) {\n let health = \"unhealthy\";\n let message = '';\n _.forEach(node.status.conditions, condition => {\n if (condition.type === \"Ready\" &&\n condition.status === \"True\") {\n health = \"ok\";\n } else {\n message = condition.message;\n }\n });\n return this.getHealthState(health, message);\n }\n\n getHealthState(health, message) {\n switch (health) {\n case 'ok': {\n return {\n text: 'OK',\n iconClass: 'icon-gf icon-gf-online',\n stateClass: 'alert-state-ok'\n };\n }\n case 'unhealthy': {\n return {\n text: 'UNHEALTHY',\n iconClass: 'icon-gf icon-gf-critical',\n stateClass: 'alert-state-critical',\n message: message || ''\n };\n }\n case 'warning': {\n return {\n text: 'warning',\n iconClass: \"icon-gf icon-gf-critical\",\n stateClass: 'alert-state-warning',\n message: message || ''\n };\n }\n }\n }\n\n refresh() {\n this.loadCluster();\n }\n\n loadDatasource(id) {\n return this.backendSrv.get('api/datasources')\n .then(result => {\n return _.filter(result, {\"type\": \"raintank-kubernetes-datasource\", \"name\": id})[0];\n })\n .then(ds => {\n if (!ds) {\n this.alertSrv.set(\"Failed to connect\", \"Could not connect to the specified cluster.\", 'error');\n throw \"Failed to connect to \" + id;\n }\n this.cluster = ds;\n return this.datasourceSrv.get(ds.name);\n }).then(clusterDS => {\n this.clusterDS = clusterDS;\n return clusterDS;\n });\n }\n\n goToNodeDashboard(node) {\n const variable = _.find(this.templateVariables, {'name': 'node'});\n variable.current.text = node === 'All' ? 'All': slugify(node.metadata.name);\n variable.current.value = node === 'All' ? '$__all': slugify(node.metadata.name);\n\n this.variableSrv.variableUpdated(variable).then(() => {\n this.$scope.$emit('template-variable-value-updated');\n this.$scope.$root.$broadcast('refresh');\n });\n }\n\n conditionStatus(condition) {\n var status;\n if (condition.type === \"Ready\") {\n status = condition.status === \"True\";\n } else {\n status = condition.status === \"False\";\n }\n\n return {\n value: status,\n text: status ? \"Ok\" : \"Error\"\n };\n }\n\n isConditionOk(condition) {\n return this.conditionStatus(condition).value;\n }\n\n conditionLastTransitionTime(condition) {\n return moment(condition.lastTransitionTime).format('YYYY-MM-DD HH:mm:ss');\n }\n}\n\nfunction slugify(str) {\n var slug = str.replace(\"@\", \"at\").replace(\"&\", \"and\").replace(/[.]/g, \"_\").replace(\"/\\W+/\", \"\");\n return slug;\n}\n\nfunction unslugify(str) {\n var slug = str.replace(/[_]/g, \".\");\n return slug;\n}\n\nNodeDataCtrl.templateUrl = 'panels/nodeData/partials/node_info.html';\n"]} \ No newline at end of file diff --git a/dist/panels/nodeData/nodeStats.js b/dist/panels/nodeData/nodeStats.js index 71f1c5c..7f70d9c 100644 --- a/dist/panels/nodeData/nodeStats.js +++ b/dist/panels/nodeData/nodeStats.js @@ -126,8 +126,8 @@ System.register(['app/core/utils/kbn', 'lodash'], function (_export, _context) { if (memData) { node.memoryUsage = _.last(memData.datapoints)[0]; var memCapacity = node.status.capacity.memory.substring(0, node.status.capacity.memory.length - 2) * 1000; - node.memUsageFormatted = kbn.valueFormats['kbytes'](node.memoryUsage, 3, null); - node.memCapacityFormatted = kbn.valueFormats['kbytes'](memCapacity, 3, null); + node.memUsageFormatted = kbn.valueFormats['bytes'](node.memoryUsage, 2, null); + node.memCapacityFormatted = kbn.valueFormats['bytes'](memCapacity, 2, null); node.memoryUsagePerc = formatFunc(node.memoryUsage / memCapacity, 2, 5); } diff --git a/dist/panels/nodeData/nodeStats.js.map b/dist/panels/nodeData/nodeStats.js.map index a696f1c..63545e6 100644 --- a/dist/panels/nodeData/nodeStats.js.map +++ b/dist/panels/nodeData/nodeStats.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../../src/panels/nodeData/nodeStats.js"],"names":["slugify","str","slug","replace","kbn","_","NodeStatsDatasource","datasourceSrv","timeSrv","graphiteDs","query","get","then","datasource","metricsQuery","range","timeRange","rangeRaw","raw","interval","intervalMs","targets","refId","target","format","maxDataPoints","result","data","cluster_id","podsPerNode","cpuPerNode","memoryPerNode","podQuery","cpuQuery","memoryQuery","issueGraphiteQuery","node","nodeStats","formatFunc","valueFormats","nodeName","metadata","name","podsUsedData","find","podsUsed","last","datapoints","podsUsedPerc","status","capacity","pods","cpuData","cpuUsage","cpuUsageFormatted","cpuUsagePerc","cpu","memData","memoryUsage","memCapacity","memory","substring","length","memUsageFormatted","memCapacityFormatted","memoryUsagePerc"],"mappings":";;;;;;;;;;;;;AA+FA,WAASA,OAAT,CAAiBC,GAAjB,EAAsB;AACpB,QAAIC,OAAOD,IAAIE,OAAJ,CAAY,GAAZ,EAAiB,IAAjB,EAAuBA,OAAvB,CAA+B,GAA/B,EAAoC,KAApC,EAA2CA,OAA3C,CAAmD,MAAnD,EAA2D,GAA3D,EAAgEA,OAAhE,CAAwE,OAAxE,EAAiF,EAAjF,CAAX;AACA,WAAOD,IAAP;AACD;;;AAlGME,S;;AACAC,O;;;;;;;;;;;;;;;;;;;;;AAEcC,yB;AACnB,qCAAYC,aAAZ,EAA2BC,OAA3B,EAAoC;AAAA;;AAClC,eAAKD,aAAL,GAAqBA,aAArB;AACA,eAAKC,OAAL,GAAeA,OAAf;AACD;;;;6CAEkBC,U,EAAYC,K,EAAO;AAAA;;AACpC,mBAAO,KAAKH,aAAL,CAAmBI,GAAnB,CAAuBF,UAAvB,EACJG,IAD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,EAAa;AACXrB,mBAAKsB,WAAL,GAAmBrD,EAAEyC,IAAF,CAAOW,QAAQV,UAAf,EAA2B,CAA3B,CAAnB;AACA,kBAAMY,cAAcvB,KAAKa,MAAL,CAAYC,QAAZ,CAAqBU,MAArB,CAA4BC,SAA5B,CAAsC,CAAtC,EAAyCzB,KAAKa,MAAL,CAAYC,QAAZ,CAAqBU,MAArB,CAA4BE,MAA5B,GAAqC,CAA9E,IAAoF,IAAxG;AACA1B,mBAAK2B,iBAAL,GAAyB3D,IAAImC,YAAJ,CAAiB,QAAjB,EAA2BH,KAAKsB,WAAhC,EAA6C,CAA7C,EAAgD,IAAhD,CAAzB;AACAtB,mBAAK4B,oBAAL,GAA4B5D,IAAImC,YAAJ,CAAiB,QAAjB,EAA2BoB,WAA3B,EAAwC,CAAxC,EAA2C,IAA3C,CAA5B;AACAvB,mBAAK6B,eAAL,GAAuB3B,WAAYF,KAAKsB,WAAL,GAAmBC,WAA/B,EAA6C,CAA7C,EAAgD,CAAhD,CAAvB;AACD;;AAED,mBAAOvB,IAAP;AACD;;;;;;yBAzFkB9B,mB","file":"nodeStats.js","sourcesContent":["import kbn from 'app/core/utils/kbn';\nimport _ from 'lodash';\n\nexport default class NodeStatsDatasource {\n constructor(datasourceSrv, timeSrv) {\n this.datasourceSrv = datasourceSrv;\n this.timeSrv = timeSrv;\n }\n\n issueGraphiteQuery(graphiteDs, query) {\n return this.datasourceSrv.get(graphiteDs)\n .then((datasource) => {\n var metricsQuery = {\n range: this.timeSrv.timeRange(),\n rangeRaw: this.timeSrv.timeRange().raw,\n interval: this.interval,\n intervalMs: this.intervalMs,\n targets: [\n {\n refId: 'A',\n target: query\n }\n ],\n format: 'json',\n maxDataPoints: 1000,\n };\n\n return datasource.query(metricsQuery);\n }).then((result) => {\n if (result && result.data) {\n return result.data;\n }\n\n return {};\n });\n }\n\n getNodeStats(cluster_id, graphiteDs) {\n let podsPerNode, cpuPerNode, memoryPerNode;\n\n const podQuery = 'aliasByNode(keepLastValue(groupByNode(snap.' + cluster_id\n + \".grafanalabs.kubestate.pod.*.*.*.status.phase.Running, 6, 'sum'), 100), 0)\";\n const cpuQuery = 'aliasByNode(keepLastValue(groupByNode(snap.' + cluster_id\n + \".grafanalabs.kubestate.container.*.*.*.*.requested.cpu.cores, 6, 'sum'), 100), 0)\";\n const memoryQuery = 'aliasByNode(keepLastValue(groupByNode(snap.' + cluster_id\n + \".grafanalabs.kubestate.container.*.*.*.*.requested.memory.bytes, 6, 'sum'), 100), 0)\";\n\n return this.issueGraphiteQuery(graphiteDs, podQuery)\n .then(data => {\n podsPerNode = data;\n return;\n }).then(() => {\n return this.issueGraphiteQuery(graphiteDs, cpuQuery);\n })\n .then(data => {\n cpuPerNode = data;\n return;\n }).then(() => {\n return this.issueGraphiteQuery(graphiteDs, memoryQuery);\n })\n .then(data => {\n memoryPerNode = data;\n return {podsPerNode, cpuPerNode, memoryPerNode};\n });\n }\n\n updateNodeWithStats(node, nodeStats) {\n var formatFunc = kbn.valueFormats['percentunit'];\n const nodeName = slugify(node.metadata.name);\n const podsUsedData = _.find(nodeStats.podsPerNode, {'target': nodeName});\n if (podsUsedData) {\n node.podsUsed = _.last(podsUsedData.datapoints)[0];\n node.podsUsedPerc = formatFunc(node.podsUsed / node.status.capacity.pods, 2, 5);\n }\n\n const cpuData = _.find(nodeStats.cpuPerNode, {'target': nodeName});\n if (cpuData) {\n node.cpuUsage = _.last(cpuData.datapoints)[0];\n node.cpuUsageFormatted = kbn.valueFormats['none'](node.cpuUsage, 2, null);\n node.cpuUsagePerc = formatFunc(node.cpuUsage / node.status.capacity.cpu, 2, 5);\n }\n\n const memData = _.find(nodeStats.memoryPerNode, {'target': nodeName});\n if (memData) {\n node.memoryUsage = _.last(memData.datapoints)[0];\n const memCapacity = node.status.capacity.memory.substring(0, node.status.capacity.memory.length - 2) * 1000;\n node.memUsageFormatted = kbn.valueFormats['kbytes'](node.memoryUsage, 3, null);\n node.memCapacityFormatted = kbn.valueFormats['kbytes'](memCapacity, 3, null);\n node.memoryUsagePerc = formatFunc((node.memoryUsage / memCapacity), 2, 5);\n }\n\n return node;\n }\n}\n\nfunction slugify(str) {\n var slug = str.replace(\"@\", \"at\").replace(\"&\", \"and\").replace(/[.]/g, \"_\").replace(\"/\\W+/\", \"\");\n return slug;\n}\n"]} \ No newline at end of file +{"version":3,"sources":["../../../src/panels/nodeData/nodeStats.js"],"names":["slugify","str","slug","replace","kbn","_","NodeStatsDatasource","datasourceSrv","timeSrv","graphiteDs","query","get","then","datasource","metricsQuery","range","timeRange","rangeRaw","raw","interval","intervalMs","targets","refId","target","format","maxDataPoints","result","data","cluster_id","podsPerNode","cpuPerNode","memoryPerNode","podQuery","cpuQuery","memoryQuery","issueGraphiteQuery","node","nodeStats","formatFunc","valueFormats","nodeName","metadata","name","podsUsedData","find","podsUsed","last","datapoints","podsUsedPerc","status","capacity","pods","cpuData","cpuUsage","cpuUsageFormatted","cpuUsagePerc","cpu","memData","memoryUsage","memCapacity","memory","substring","length","memUsageFormatted","memCapacityFormatted","memoryUsagePerc"],"mappings":";;;;;;;;;;;;;AA+FA,WAASA,OAAT,CAAiBC,GAAjB,EAAsB;AACpB,QAAIC,OAAOD,IAAIE,OAAJ,CAAY,GAAZ,EAAiB,IAAjB,EAAuBA,OAAvB,CAA+B,GAA/B,EAAoC,KAApC,EAA2CA,OAA3C,CAAmD,MAAnD,EAA2D,GAA3D,EAAgEA,OAAhE,CAAwE,OAAxE,EAAiF,EAAjF,CAAX;AACA,WAAOD,IAAP;AACD;;;AAlGME,S;;AACAC,O;;;;;;;;;;;;;;;;;;;;;AAEcC,yB;AACnB,qCAAYC,aAAZ,EAA2BC,OAA3B,EAAoC;AAAA;;AAClC,eAAKD,aAAL,GAAqBA,aAArB;AACA,eAAKC,OAAL,GAAeA,OAAf;AACD;;;;6CAEkBC,U,EAAYC,K,EAAO;AAAA;;AACpC,mBAAO,KAAKH,aAAL,CAAmBI,GAAnB,CAAuBF,UAAvB,EACJG,IADI,C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AAa;AACXrB,mBAAKsB,WAAL,GAAmBrD,EAAEyC,IAAF,CAAOW,QAAQV,UAAf,EAA2B,CAA3B,CAAnB;AACA,kBAAMY,cAAcvB,KAAKa,MAAL,CAAYC,QAAZ,CAAqBU,MAArB,CAA4BC,SAA5B,CAAsC,CAAtC,EAAyCzB,KAAKa,MAAL,CAAYC,QAAZ,CAAqBU,MAArB,CAA4BE,MAA5B,GAAqC,CAA9E,IAAoF,IAAxG;AACA1B,mBAAK2B,iBAAL,GAAyB3D,IAAImC,YAAJ,CAAiB,OAAjB,EAA0BH,KAAKsB,WAA/B,EAA4C,CAA5C,EAA+C,IAA/C,CAAzB;AACAtB,mBAAK4B,oBAAL,GAA4B5D,IAAImC,YAAJ,CAAiB,OAAjB,EAA0BoB,WAA1B,EAAuC,CAAvC,EAA0C,IAA1C,CAA5B;AACAvB,mBAAK6B,eAAL,GAAuB3B,WAAYF,KAAKsB,WAAL,GAAmBC,WAA/B,EAA6C,CAA7C,EAAgD,CAAhD,CAAvB;AACD;;AAED,mBAAOvB,IAAP;AACD;;;;;;yBAzFkB9B,mB","file":"nodeStats.js","sourcesContent":["import kbn from 'app/core/utils/kbn';\nimport _ from 'lodash';\n\nexport default class NodeStatsDatasource {\n constructor(datasourceSrv, timeSrv) {\n this.datasourceSrv = datasourceSrv;\n this.timeSrv = timeSrv;\n }\n\n issueGraphiteQuery(graphiteDs, query) {\n return this.datasourceSrv.get(graphiteDs)\n .then((datasource) => {\n var metricsQuery = {\n range: this.timeSrv.timeRange(),\n rangeRaw: this.timeSrv.timeRange().raw,\n interval: this.interval,\n intervalMs: this.intervalMs,\n targets: [\n {\n refId: 'A',\n target: query\n }\n ],\n format: 'json',\n maxDataPoints: 1000,\n };\n\n return datasource.query(metricsQuery);\n }).then((result) => {\n if (result && result.data) {\n return result.data;\n }\n\n return {};\n });\n }\n\n getNodeStats(cluster_id, graphiteDs) {\n let podsPerNode, cpuPerNode, memoryPerNode;\n\n const podQuery = 'aliasByNode(keepLastValue(groupByNode(snap.' + cluster_id\n + \".grafanalabs.kubestate.pod.*.*.*.status.phase.Running, 6, 'sum'), 100), 0)\";\n const cpuQuery = 'aliasByNode(keepLastValue(groupByNode(snap.' + cluster_id\n + \".grafanalabs.kubestate.container.*.*.*.*.requested.cpu.cores, 6, 'sum'), 100), 0)\";\n const memoryQuery = 'aliasByNode(keepLastValue(groupByNode(snap.' + cluster_id\n + \".grafanalabs.kubestate.container.*.*.*.*.requested.memory.bytes, 6, 'sum'), 100), 0)\";\n\n return this.issueGraphiteQuery(graphiteDs, podQuery)\n .then(data => {\n podsPerNode = data;\n return;\n }).then(() => {\n return this.issueGraphiteQuery(graphiteDs, cpuQuery);\n })\n .then(data => {\n cpuPerNode = data;\n return;\n }).then(() => {\n return this.issueGraphiteQuery(graphiteDs, memoryQuery);\n })\n .then(data => {\n memoryPerNode = data;\n return {podsPerNode, cpuPerNode, memoryPerNode};\n });\n }\n\n updateNodeWithStats(node, nodeStats) {\n var formatFunc = kbn.valueFormats['percentunit'];\n const nodeName = slugify(node.metadata.name);\n const podsUsedData = _.find(nodeStats.podsPerNode, {'target': nodeName});\n if (podsUsedData) {\n node.podsUsed = _.last(podsUsedData.datapoints)[0];\n node.podsUsedPerc = formatFunc(node.podsUsed / node.status.capacity.pods, 2, 5);\n }\n\n const cpuData = _.find(nodeStats.cpuPerNode, {'target': nodeName});\n if (cpuData) {\n node.cpuUsage = _.last(cpuData.datapoints)[0];\n node.cpuUsageFormatted = kbn.valueFormats['none'](node.cpuUsage, 2, null);\n node.cpuUsagePerc = formatFunc(node.cpuUsage / node.status.capacity.cpu, 2, 5);\n }\n\n const memData = _.find(nodeStats.memoryPerNode, {'target': nodeName});\n if (memData) {\n node.memoryUsage = _.last(memData.datapoints)[0];\n const memCapacity = node.status.capacity.memory.substring(0, node.status.capacity.memory.length - 2) * 1000;\n node.memUsageFormatted = kbn.valueFormats['bytes'](node.memoryUsage, 2, null);\n node.memCapacityFormatted = kbn.valueFormats['bytes'](memCapacity, 2, null);\n node.memoryUsagePerc = formatFunc((node.memoryUsage / memCapacity), 2, 5);\n }\n\n return node;\n }\n}\n\nfunction slugify(str) {\n var slug = str.replace(\"@\", \"at\").replace(\"&\", \"and\").replace(/[.]/g, \"_\").replace(\"/\\W+/\", \"\");\n return slug;\n}\n"]} \ No newline at end of file diff --git a/dist/panels/podNav/podNav.js b/dist/panels/podNav/podNav.js index b3132a4..274b377 100644 --- a/dist/panels/podNav/podNav.js +++ b/dist/panels/podNav/podNav.js @@ -3,7 +3,7 @@ System.register(['app/plugins/sdk', 'lodash'], function (_export, _context) { "use strict"; - var PanelCtrl, _, _typeof, _createClass, panelDefaults, PodNavCtrl; + var PanelCtrl, _, _createClass, panelDefaults, PodNavCtrl; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { @@ -42,12 +42,6 @@ System.register(['app/plugins/sdk', 'lodash'], function (_export, _context) { _ = _lodash.default; }], execute: function () { - _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { - return typeof obj; - } : function (obj) { - return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; - }; - _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { @@ -168,21 +162,15 @@ System.register(['app/plugins/sdk', 'lodash'], function (_export, _context) { if (this.currentPods.length === 0) { if (_.isArray(this.namespace)) { - var _ret = function () { - var promises = []; - _.forEach(_this3.namespace, function (ns) { - promises.push(_this3.clusterDS.getPods(ns)); + var promises = []; + _.forEach(this.namespace, function (ns) { + promises.push(_this3.clusterDS.getPods(ns)); + }); + return this.$q.all(promises).then(function (pods) { + return _.flatten(pods).filter(function (n) { + return n; }); - return { - v: _this3.$q.all(promises).then(function (pods) { - return _.flatten(pods).filter(function (n) { - return n; - }); - }) - }; - }(); - - if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v; + }); } else { return this.clusterDS.getPods(this.namespace); } @@ -230,21 +218,15 @@ System.register(['app/plugins/sdk', 'lodash'], function (_export, _context) { var _this6 = this; if (_.isArray(this.namespace)) { - var _ret2 = function () { - var promises = []; - _.forEach(_this6.namespace, function (ns) { - promises.push(_this6.clusterDS.getPodsByLabel(ns, _this6.chosenTags)); + var promises = []; + _.forEach(this.namespace, function (ns) { + promises.push(_this6.clusterDS.getPodsByLabel(ns, _this6.chosenTags)); + }); + return this.$q.all(promises).then(function (pods) { + return _.flatten(pods).filter(function (n) { + return n; }); - return { - v: _this6.$q.all(promises).then(function (pods) { - return _.flatten(pods).filter(function (n) { - return n; - }); - }) - }; - }(); - - if ((typeof _ret2 === 'undefined' ? 'undefined' : _typeof(_ret2)) === "object") return _ret2.v; + }); } else { return this.clusterDS.getPodsByLabel(this.namespace, this.chosenTags); } diff --git a/dist/panels/podNav/podNav.js.map b/dist/panels/podNav/podNav.js.map index 8ff7bd6..f6aa817 100644 --- a/dist/panels/podNav/podNav.js.map +++ b/dist/panels/podNav/podNav.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../../src/panels/podNav/podNav.js"],"names":["PanelCtrl","_","panelDefaults","PodNavCtrl","$scope","$injector","backendSrv","datasourceSrv","$location","alertSrv","variableSrv","$q","defaults","panel","templateVariables","variables","namespace","currentTags","currentPods","selectedPods","setDefaults","loadTags","chosenTags","needsRefresh","cluster","find","ns","clusterName","current","value","getCluster","then","getPods","parseTagsFromPods","pods","uniq","map","p","metadata","name","set","podVariable","isArray","length","promises","forEach","push","clusterDS","all","flatten","filter","n","getPodsByName","pod","labels","label","includes","removeEmptyTags","getPodsByLabel","updateTemplateVariableWithPods","variable","text","join","isEmpty","updateOptions","variableUpdated","$emit","$root","$broadcast","omitBy","val","get","result","ds","jsonData","tag","podName","remove","templateUrl"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAQA,e,kBAAAA,S;;AACDC,O;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEDC,mB,GAAgB,E;;4BAGTC,U;;;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;AACD,aALD;AAMD;;;oCAESiB,O,EAAS;AACjB,iBAAKtD,UAAL,GAAkB,EAAlB;;AAEA,gBAAI,CAAC,KAAKH,YAAL,CAAkBqC,QAAlB,CAA2BoB,OAA3B,CAAL,EAA0C;AACxC,mBAAKzD,YAAL,CAAkB2B,IAAlB,CAAuB8B,OAAvB;AACD;;AAED,iBAAKjB,8BAAL;AACD;;;uCAEYiB,O,EAAS;AACpB3E,cAAE4E,MAAF,CAAS,KAAK1D,YAAd,EAA4B,aAAK;AAAE,qBAAOkB,MAAMuC,OAAb;AAAsB,aAAzD;AACA,iBAAKjB,8BAAL;;AAEA,gBAAI,KAAKxC,YAAL,CAAkBwB,MAAlB,KAA6B,CAAjC,EAAoC;AAClC,mBAAKzB,WAAL,GAAmB,EAAnB;AACA,mBAAKG,QAAL;AACD;AACF;;;;QAnN6BrB,S;;;;AAsNhCG,iBAAW2E,WAAX,GAAyB,qCAAzB","file":"podNav.js","sourcesContent":["import {PanelCtrl} from 'app/plugins/sdk';\nimport _ from 'lodash';\n\nconst panelDefaults = {\n};\n\nexport class PodNavCtrl extends PanelCtrl {\n constructor($scope, $injector, backendSrv, datasourceSrv, $location, alertSrv, variableSrv, $q) {\n super($scope, $injector);\n _.defaults(this.panel, panelDefaults);\n\n this.backendSrv = backendSrv;\n this.datasourceSrv = datasourceSrv;\n this.$location = $location;\n this.alertSrv = alertSrv;\n this.variableSrv = variableSrv;\n this.$q = $q;\n\n this.templateVariables = this.variableSrv.variables;\n this.namespace = \"All\";\n this.currentTags = {};\n this.currentPods = [];\n this.selectedPods = [];\n\n this.setDefaults();\n this.loadTags();\n this.chosenTags = {};\n }\n\n refresh() {\n if (this.needsRefresh()) {\n this.currentTags = {};\n this.currentPods = [];\n this.chosenTags = {};\n this.selectedPods = [];\n\n this.setDefaults();\n this.loadTags();\n }\n }\n\n needsRefresh() {\n const cluster = _.find(this.templateVariables, {'name': 'cluster'});\n const ns = _.find(this.templateVariables, {'name': 'namespace'});\n\n if (this.clusterName !== cluster.current.value) { return true; }\n\n if ((ns.current.value === '$__all' || ns.current.value[0] === '$__all')\n && (this.namespace === ns.current.value || this.namespace === '')) {\n return false;\n }\n\n if (ns.current.value !== this.namespace) { return true; }\n\n return false;\n }\n\n loadTags() {\n this.getCluster().then(() => {\n return this.getPods().then(pods => {\n this.parseTagsFromPods(pods);\n this.currentPods = _.uniq(_.map(pods, p => { return p.metadata.name; }));\n });\n });\n }\n\n setDefaults() {\n const cluster = _.find(this.templateVariables, {'name': 'cluster'});\n if (!cluster) {\n this.alertSrv.set(\"no cluster specified.\", \"no cluster specified in url\", 'error');\n return;\n }\n\n const ns = _.find(this.templateVariables, {'name': 'namespace'});\n this.namespace = ns.current.value !== '$__all' && ns.current.value[0] !== '$__all' ? ns.current.value : '';\n const podVariable = _.find(this.templateVariables, {'name': 'pod'});\n\n if (podVariable.current.value !== '$__all') {\n this.selectedPods = _.isArray(podVariable.current.value) ? podVariable.current.value : [podVariable.current.value];\n }\n }\n\n getPods() {\n if (this.currentPods.length === 0) {\n if (_.isArray(this.namespace)) {\n const promises = [];\n _.forEach(this.namespace, ns => {\n promises.push(this.clusterDS.getPods(ns));\n });\n return this.$q.all(promises)\n .then(pods => {\n return _.flatten(pods).filter(n => n);\n });\n } else {\n return this.clusterDS.getPods(this.namespace);\n }\n } else {\n return this.clusterDS.getPodsByName(this.currentPods);\n }\n }\n\n parseTagsFromPods(pods) {\n this.currentTags = {};\n\n _.forEach(pods, pod => {\n _.forEach(pod.metadata.labels, (value, label) => {\n if (!this.currentTags[label]) {\n this.currentTags[label] = [];\n }\n if (!this.currentTags[label].includes(value)) {\n this.currentTags[label].push(value);\n }\n });\n });\n }\n\n onTagSelect() {\n this.removeEmptyTags();\n this.selectedPods = [];\n\n this.getPodsByLabel()\n .then(pods => {\n this.currentPods = _.uniq(_.map(pods, p => { return p.metadata.name; }));\n this.parseTagsFromPods(pods);\n this.updateTemplateVariableWithPods();\n });\n }\n\n getPodsByLabel() {\n if (_.isArray(this.namespace)) {\n const promises = [];\n _.forEach(this.namespace, ns => {\n promises.push(this.clusterDS.getPodsByLabel(ns, this.chosenTags));\n });\n return this.$q.all(promises)\n .then(pods => {\n return _.flatten(pods).filter(n => n);\n });\n } else {\n return this.clusterDS.getPodsByLabel(this.namespace, this.chosenTags);\n }\n }\n\n updateTemplateVariableWithPods() {\n const variable = _.find(this.templateVariables, {'name': 'pod'});\n\n if (this.selectedPods.length > 0) {\n variable.current.text = this.selectedPods.join(' + ');\n variable.current.value = this.selectedPods;\n } else {\n variable.current.text = _.isEmpty(this.chosenTags) ? 'All': this.currentPods.join(' + ');\n variable.current.value = _.isEmpty(this.chosenTags) ? '$__all': this.currentPods;\n }\n\n this.variableSrv.updateOptions(variable).then(() => {\n this.variableSrv.variableUpdated(variable).then(() => {\n this.$scope.$emit('template-variable-value-updated');\n this.$scope.$root.$broadcast('refresh');\n });\n });\n }\n\n removeEmptyTags() {\n this.chosenTags = _.omitBy(this.chosenTags, val => { return !val;});\n }\n\n getCluster() {\n const clusterName = _.find(this.templateVariables, {'name': 'cluster'}).current.value;\n this.clusterName = clusterName;\n\n return this.backendSrv.get('/api/datasources')\n .then(result => {\n return _.filter(result, {\"name\": clusterName})[0];\n })\n .then((ds) => {\n if (!ds) {\n this.alertSrv.set(\"Failed to connect\", \"Could not connect to the specified cluster.\", 'error');\n throw \"Failed to connect to \" + clusterName;\n }\n\n if (!(ds.jsonData.ds)) {\n ds.jsonData.ds = \"\";\n }\n return this.datasourceSrv.get(ds.name);\n }).then(clusterDS => {\n this.clusterDS = clusterDS;\n });\n }\n\n removeTag(tag) {\n delete this.chosenTags[tag];\n this.getPodsByLabel()\n .then(pods => {\n this.currentPods = _.uniq(_.map(pods, p => { return p.metadata.name; }));\n this.parseTagsFromPods(pods);\n this.updateTemplateVariableWithPods();\n });\n }\n\n selectPod(podName) {\n this.chosenTags = {};\n\n if (!this.selectedPods.includes(podName)) {\n this.selectedPods.push(podName);\n }\n\n this.updateTemplateVariableWithPods();\n }\n\n removePodTag(podName) {\n _.remove(this.selectedPods, p => { return p === podName;});\n this.updateTemplateVariableWithPods();\n\n if (this.selectedPods.length === 0) {\n this.currentPods = [];\n this.loadTags();\n }\n }\n}\n\nPodNavCtrl.templateUrl = 'panels/podNav/partials/pod_nav.html';\n"]} \ No newline at end of file +{"version":3,"sources":["../../../src/panels/podNav/podNav.js"],"names":["PanelCtrl","_","panelDefaults","PodNavCtrl","$scope","$injector","backendSrv","datasourceSrv","$location","alertSrv","variableSrv","$q","defaults","panel","templateVariables","variables","namespace","currentTags","currentPods","selectedPods","setDefaults","loadTags","chosenTags","needsRefresh","cluster","find","ns","clusterName","current","value","getCluster","then","getPods","parseTagsFromPods","pods","uniq","map","p","metadata","name","set","podVariable","isArray","length","promises","forEach","push","clusterDS","all","flatten","filter","n","getPodsByName","pod","labels","label","includes","removeEmptyTags","getPodsByLabel","updateTemplateVariableWithPods","variable","text","join","isEmpty","updateOptions","variableUpdated","$emit","$root","$broadcast","omitBy","val","get","result","ds","jsonData","tag","podName","remove","templateUrl"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAQA,e,kBAAAA,S;;AACDC,O;;;;;;;;;;;;;;;;;;;;;AAEDC,mB,GAAgB,E;;4BAGTC,U;;;AACX,4BAAYC,MAAZ,EAAoBC,SAApB,EAA+BC,UAA/B,EAA2CC,aAA3C,EAA0DC,SAA1D,EAAqEC,QAArE,EAA+EC,WAA/E,EAA4FC,EAA5F,EAAgG;AAAA;;AAAA,8HACxFP,MADwF,EAChFC,SADgF;;AAE9FJ,YAAEW,QAAF,CAAW,MAAKC,KAAhB,EAAuBX,aAAvB;;AAEA,gBAAKI,UAAL,GAAkBA,UAAlB;AACA,gBAAKC,aAAL,GAAqBA,aAArB;AACA,gBAAKC,SAAL,GAAiBA,SAAjB;AACA,gBAAKC,QAAL,GAAgBA,QAAhB;AACA,gBAAKC,WAAL,GAAmBA,WAAnB;AACA,gBAAKC,EAAL,GAAUA,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G,QAAL;AACD;AACF;;;;QAnN6BrB,S;;;;AAsNhCG,iBAAW2E,WAAX,GAAyB,qCAAzB","file":"podNav.js","sourcesContent":["import {PanelCtrl} from 'app/plugins/sdk';\nimport _ from 'lodash';\n\nconst panelDefaults = {\n};\n\nexport class PodNavCtrl extends PanelCtrl {\n constructor($scope, $injector, backendSrv, datasourceSrv, $location, alertSrv, variableSrv, $q) {\n super($scope, $injector);\n _.defaults(this.panel, panelDefaults);\n\n this.backendSrv = backendSrv;\n this.datasourceSrv = datasourceSrv;\n this.$location = $location;\n this.alertSrv = alertSrv;\n this.variableSrv = variableSrv;\n this.$q = $q;\n\n this.templateVariables = this.variableSrv.variables;\n this.namespace = \"All\";\n this.currentTags = {};\n this.currentPods = [];\n this.selectedPods = [];\n\n this.setDefaults();\n this.loadTags();\n this.chosenTags = {};\n }\n\n refresh() {\n if (this.needsRefresh()) {\n this.currentTags = {};\n this.currentPods = [];\n this.chosenTags = {};\n this.selectedPods = [];\n\n this.setDefaults();\n this.loadTags();\n }\n }\n\n needsRefresh() {\n const cluster = _.find(this.templateVariables, {'name': 'cluster'});\n const ns = _.find(this.templateVariables, {'name': 'namespace'});\n\n if (this.clusterName !== cluster.current.value) { return true; }\n\n if ((ns.current.value === '$__all' || ns.current.value[0] === '$__all')\n && (this.namespace === ns.current.value || this.namespace === '')) {\n return false;\n }\n\n if (ns.current.value !== this.namespace) { return true; }\n\n return false;\n }\n\n loadTags() {\n this.getCluster().then(() => {\n return this.getPods().then(pods => {\n this.parseTagsFromPods(pods);\n this.currentPods = _.uniq(_.map(pods, p => { return p.metadata.name; }));\n });\n });\n }\n\n setDefaults() {\n const cluster = _.find(this.templateVariables, {'name': 'cluster'});\n if (!cluster) {\n this.alertSrv.set(\"no cluster specified.\", \"no cluster specified in url\", 'error');\n return;\n }\n\n const ns = _.find(this.templateVariables, {'name': 'namespace'});\n this.namespace = ns.current.value !== '$__all' && ns.current.value[0] !== '$__all' ? ns.current.value : '';\n const podVariable = _.find(this.templateVariables, {'name': 'pod'});\n\n if (podVariable.current.value !== '$__all') {\n this.selectedPods = _.isArray(podVariable.current.value) ? podVariable.current.value : [podVariable.current.value];\n }\n }\n\n getPods() {\n if (this.currentPods.length === 0) {\n if (_.isArray(this.namespace)) {\n const promises = [];\n _.forEach(this.namespace, ns => {\n promises.push(this.clusterDS.getPods(ns));\n });\n return this.$q.all(promises)\n .then(pods => {\n return _.flatten(pods).filter(n => n);\n });\n } else {\n return this.clusterDS.getPods(this.namespace);\n }\n } else {\n return this.clusterDS.getPodsByName(this.currentPods);\n }\n }\n\n parseTagsFromPods(pods) {\n this.currentTags = {};\n\n _.forEach(pods, pod => {\n _.forEach(pod.metadata.labels, (value, label) => {\n if (!this.currentTags[label]) {\n this.currentTags[label] = [];\n }\n if (!this.currentTags[label].includes(value)) {\n this.currentTags[label].push(value);\n }\n });\n });\n }\n\n onTagSelect() {\n this.removeEmptyTags();\n this.selectedPods = [];\n\n this.getPodsByLabel()\n .then(pods => {\n this.currentPods = _.uniq(_.map(pods, p => { return p.metadata.name; }));\n this.parseTagsFromPods(pods);\n this.updateTemplateVariableWithPods();\n });\n }\n\n getPodsByLabel() {\n if (_.isArray(this.namespace)) {\n const promises = [];\n _.forEach(this.namespace, ns => {\n promises.push(this.clusterDS.getPodsByLabel(ns, this.chosenTags));\n });\n return this.$q.all(promises)\n .then(pods => {\n return _.flatten(pods).filter(n => n);\n });\n } else {\n return this.clusterDS.getPodsByLabel(this.namespace, this.chosenTags);\n }\n }\n\n updateTemplateVariableWithPods() {\n const variable = _.find(this.templateVariables, {'name': 'pod'});\n\n if (this.selectedPods.length > 0) {\n variable.current.text = this.selectedPods.join(' + ');\n variable.current.value = this.selectedPods;\n } else {\n variable.current.text = _.isEmpty(this.chosenTags) ? 'All': this.currentPods.join(' + ');\n variable.current.value = _.isEmpty(this.chosenTags) ? '$__all': this.currentPods;\n }\n\n this.variableSrv.updateOptions(variable).then(() => {\n this.variableSrv.variableUpdated(variable).then(() => {\n this.$scope.$emit('template-variable-value-updated');\n this.$scope.$root.$broadcast('refresh');\n });\n });\n }\n\n removeEmptyTags() {\n this.chosenTags = _.omitBy(this.chosenTags, val => { return !val;});\n }\n\n getCluster() {\n const clusterName = _.find(this.templateVariables, {'name': 'cluster'}).current.value;\n this.clusterName = clusterName;\n\n return this.backendSrv.get('/api/datasources')\n .then(result => {\n return _.filter(result, {\"name\": clusterName})[0];\n })\n .then((ds) => {\n if (!ds) {\n this.alertSrv.set(\"Failed to connect\", \"Could not connect to the specified cluster.\", 'error');\n throw \"Failed to connect to \" + clusterName;\n }\n\n if (!(ds.jsonData.ds)) {\n ds.jsonData.ds = \"\";\n }\n return this.datasourceSrv.get(ds.name);\n }).then(clusterDS => {\n this.clusterDS = clusterDS;\n });\n }\n\n removeTag(tag) {\n delete this.chosenTags[tag];\n this.getPodsByLabel()\n .then(pods => {\n this.currentPods = _.uniq(_.map(pods, p => { return p.metadata.name; }));\n this.parseTagsFromPods(pods);\n this.updateTemplateVariableWithPods();\n });\n }\n\n selectPod(podName) {\n this.chosenTags = {};\n\n if (!this.selectedPods.includes(podName)) {\n this.selectedPods.push(podName);\n }\n\n this.updateTemplateVariableWithPods();\n }\n\n removePodTag(podName) {\n _.remove(this.selectedPods, p => { return p === podName;});\n this.updateTemplateVariableWithPods();\n\n if (this.selectedPods.length === 0) {\n this.currentPods = [];\n this.loadTags();\n }\n }\n}\n\nPodNavCtrl.templateUrl = 'panels/podNav/partials/pod_nav.html';\n"]} \ No newline at end of file diff --git a/src/panels/nodeData/nodeStats.js b/src/panels/nodeData/nodeStats.js index 1a1199d..17156f7 100644 --- a/src/panels/nodeData/nodeStats.js +++ b/src/panels/nodeData/nodeStats.js @@ -84,8 +84,8 @@ export default class NodeStatsDatasource { if (memData) { node.memoryUsage = _.last(memData.datapoints)[0]; const memCapacity = node.status.capacity.memory.substring(0, node.status.capacity.memory.length - 2) * 1000; - node.memUsageFormatted = kbn.valueFormats['kbytes'](node.memoryUsage, 3, null); - node.memCapacityFormatted = kbn.valueFormats['kbytes'](memCapacity, 3, null); + node.memUsageFormatted = kbn.valueFormats['bytes'](node.memoryUsage, 2, null); + node.memCapacityFormatted = kbn.valueFormats['bytes'](memCapacity, 2, null); node.memoryUsagePerc = formatFunc((node.memoryUsage / memCapacity), 2, 5); }