This commit is contained in:
parent
fb07b6a320
commit
25c335da59
38
main.js
38
main.js
|
@ -1,22 +1,34 @@
|
||||||
const fetch = require('node-fetch');
|
const fetch = require('node-fetch');
|
||||||
const colors = require('colors');
|
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 findAll = "vn.client";
|
||||||
|
|
||||||
|
const urlDashboards = "https://grafana.verdnatura.es/api/search";
|
||||||
|
const urlUID = "https://grafana.verdnatura.es/api/dashboards/uid/";
|
||||||
|
const apiKey = "Bearer eyJrIjoiaHczdnZsOGd5M0xNUHJwZ3V4MGpvQzV0QVNGblpySloiLCJuIjoiZmluZEFsbF9HcmFmYW5hIiwiaWQiOjF9";
|
||||||
|
let numberOfResults = 0;
|
||||||
|
|
||||||
const regexRawSQL = new RegExp(findAll, 'i');
|
const regexRawSQL = new RegExp(findAll, 'i');
|
||||||
const myArray = grafana.split(delimiter);
|
|
||||||
/*https://grafana.verdnatura.es/api/search*/
|
|
||||||
|
|
||||||
async function main(){
|
async function main(){
|
||||||
for (let i=0; i < myArray.length; i++) {
|
|
||||||
|
|
||||||
let url = "https://grafana.verdnatura.es/api/dashboards/uid/" + myArray[i];
|
console.clear();
|
||||||
|
|
||||||
|
let responseAllUID = await fetch(urlDashboards, {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Authorization": apiKey,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
let allUID = await responseAllUID.json();
|
||||||
|
|
||||||
|
for (let i=0; i < allUID.length; i++) {
|
||||||
|
|
||||||
|
let url = urlUID + allUID[i].uid;
|
||||||
let response = await fetch(url, {
|
let response = await fetch(url, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
"Authorization": "Bearer eyJrIjoiaHczdnZsOGd5M0xNUHJwZ3V4MGpvQzV0QVNGblpySloiLCJuIjoiZmluZEFsbF9HcmFmYW5hIiwiaWQiOjF9",
|
"Authorization": apiKey,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
let data = await response.json();
|
let data = await response.json();
|
||||||
|
@ -39,8 +51,16 @@ async function main(){
|
||||||
if (isFound) break;
|
if (isFound) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isFound)
|
if (isFound) {
|
||||||
console.log('https://grafana.verdnatura.es/d/' + `${myArray[i]}:`, colors.green(isFound));
|
console.log(colors.randomColor('https://grafana.verdnatura.es/d/' + allUID[i].uid));
|
||||||
|
numberOfResults++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (numberOfResults==0)
|
||||||
|
console.log("No se han encontrado resultados".red);
|
||||||
|
else
|
||||||
|
console.log(colors.green.bold("---- Se han encontrado " + numberOfResults + " resultados ----"));
|
||||||
|
|
||||||
}
|
}
|
||||||
main();
|
main();
|
Loading…
Reference in New Issue