This commit is contained in:
parent
09b5c8047f
commit
fb07b6a320
|
@ -0,0 +1,46 @@
|
|||
const fetch = require('node-fetch');
|
||||
const colors = require('colors');
|
||||
|
||||
const grafana = "0JQGVd17k,2kaHDi9Mk,2unJ5DJnz,4NoNjDNnz,4lYKRi9Gk,5tTwzgsGz,7XcE-x-Wz,8-fqFVkMz,8DAxd31nz,8UMbCpu7k,8pQEQODnz,9H3mUIsMk,9nobGlwnz,AnCRQmA7z,AuTDo9Jnz,BBFXc5sGk,CfZJcWV7k,Cjc6nn-nk,E5_uc4T7z,E7j0G_w7z,F8OlxJo7k,FhqWmeYnz,GNdlFvw7z,II7k2Zrnz,Iao2L197k,Iqd3I5d7z,IsrZyXn7k,Jr24DEB7z,JrpXuDH7k,K0zrySyGk,KBZB1irnz,KgBor-W7z,NILbmd17k,Pj9wvQd7z,PrdD1meWk,RHv9vnYnz,SznAihXnk,T9Ymh_6Gz,T9m5uGEWk,TNS6uzcMk,TT_taT9nk,Tjd73I_7k,TudUK-jnk,U-lYgzxnk,VptulAznk,W2cbuExMk,X6dZrjEGk,XAlCcZA7k,XVvG8IsGz,Xqm6kPonk,ZiXs9VE7z,_QLGJ7wnz,_UeQygu7k,aMO-J8F7k,aPGvnjw7z,bK25D91nz,c0Hrkzunz,c9jJCCx7k,cACgeLWnk,ch4PmVB7k,cv36OPfnk,cw9_1NPGk,erpDsePGz,fCu6VduGz,fXoeoOv7k,fuusUxbnz,g-N7CE57k,gpITUSsGz,hG9phnMnz,hWFz_nm7k,hboD-hu7k,iJE3Ap9nz,iMzV8SsMk,i__5md17k,j8lmJ-Unz,lV3Rg3Jnk,lyqP98f7z,mvnxOoa7z,n-Z8l-B7k,oPW0X9Lnk,p0dM_oa7z,pq29M097z,sGjEGaX7z,tx77ieLnz,uvOwigsMz,w4XEL_xnk,w9w3Uo-7z,whXjzKv7k,wpD7ILrnk,wqH4Y6EMz,xSIMUHB7z,x_kkKL9nk,xoFDqNBnz,yk96BLw7k,zEx8L817z,4UC0PZCnk";
|
||||
const delimiter = ",";
|
||||
const findAll = "vn.client";
|
||||
|
||||
const regexRawSQL = new RegExp(findAll, 'i');
|
||||
const myArray = grafana.split(delimiter);
|
||||
/*https://grafana.verdnatura.es/api/search*/
|
||||
|
||||
async function main(){
|
||||
for (let i=0; i < myArray.length; i++) {
|
||||
|
||||
let url = "https://grafana.verdnatura.es/api/dashboards/uid/" + myArray[i];
|
||||
let response = await fetch(url, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Authorization": "Bearer eyJrIjoiaHczdnZsOGd5M0xNUHJwZ3V4MGpvQzV0QVNGblpySloiLCJuIjoiZmluZEFsbF9HcmFmYW5hIiwiaWQiOjF9",
|
||||
}
|
||||
});
|
||||
let data = await response.json();
|
||||
|
||||
let isFound = false;
|
||||
|
||||
const dashboard = data.dashboard;
|
||||
if (dashboard) {
|
||||
if (dashboard.panels)
|
||||
panelsLoop: for (const panel of dashboard.panels)
|
||||
if (panel.targets)
|
||||
for (const target of panel.targets) {
|
||||
isFound = regexRawSQL.test(target.rawSql);
|
||||
if (isFound) break panelsLoop;
|
||||
}
|
||||
|
||||
if (dashboard.templating && !isFound)
|
||||
for (const list of dashboard.templating.list) {
|
||||
isFound = regexRawSQL.test(list.query);
|
||||
if (isFound) break;
|
||||
}
|
||||
}
|
||||
if (isFound)
|
||||
console.log('https://grafana.verdnatura.es/d/' + `${myArray[i]}:`, colors.green(isFound));
|
||||
}
|
||||
}
|
||||
main();
|
Loading…
Reference in New Issue