Ahora ya busca bien en todas las organizaciones
This commit is contained in:
parent
cb8fd76e46
commit
034f6d1f82
45
main.js
45
main.js
|
@ -126,14 +126,20 @@ async function main(){
|
|||
|
||||
if (AllOrganizations.message==='invalid username or password') {
|
||||
console.error(`\n${error}Invalid username or password\n`.red);
|
||||
process.exit(0);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.clear();
|
||||
console.log(
|
||||
`----------`.white,
|
||||
`Grafana-Find (${packageJson.description})`.yellow.bold,
|
||||
`v${packageJson.version}`.cyan.bold,
|
||||
`---------`.white
|
||||
);
|
||||
console.log(colors.green.bold(`-------------------- Starting process --------------------\n`));
|
||||
|
||||
for (let x in AllOrganizations) {
|
||||
|
||||
|
||||
console.log(colors.gray.bold(`(Organization: ${AllOrganizations[x].name})\n`));
|
||||
response = await fetch(`${urlDashboards}${AllOrganizations[x].id}`, {
|
||||
method: "GET",
|
||||
|
@ -146,26 +152,39 @@ async function main(){
|
|||
if (response.status === 302) {
|
||||
response = await fetch(`${urlDashboards}${AllOrganizations[x].id}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Accept: 'application/json'
|
||||
},
|
||||
redirect: 'manual'
|
||||
});
|
||||
}
|
||||
|
||||
let allUID = await response.json();
|
||||
|
||||
|
||||
for (let i in allUID) {
|
||||
|
||||
let url = urlUID + allUID[i].uid;
|
||||
let url = `${urlUID}${allUID[i].uid}`;
|
||||
response = await fetch(url, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
Authorization: credentials,
|
||||
}
|
||||
},
|
||||
redirect: 'manual'
|
||||
});
|
||||
|
||||
|
||||
if (response.status === 404) {
|
||||
response = await fetch(url, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Accept: 'application/json'
|
||||
},
|
||||
redirect: 'manual'
|
||||
});
|
||||
}
|
||||
|
||||
let data = await response.json();
|
||||
|
||||
|
||||
let isFound = false;
|
||||
|
||||
|
||||
const dashboard = data.dashboard;
|
||||
if (dashboard) {
|
||||
if (dashboard.panels)
|
||||
|
@ -182,7 +201,7 @@ async function main(){
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (dashboard.templating)
|
||||
for (const list of dashboard.templating.list) {
|
||||
isFound = regexRawSQL.test(list.query);
|
||||
|
@ -192,7 +211,7 @@ async function main(){
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (isFound) {
|
||||
const linkUrl = `${grafanaUrl}/d/${allUID[i].uid}`;
|
||||
console.log(colors.yellow(linkUrl));
|
||||
|
@ -207,7 +226,7 @@ async function main(){
|
|||
console.log('')
|
||||
numberOfDashboards++;
|
||||
}
|
||||
|
||||
|
||||
titlePanels = [];
|
||||
nameVariables= [];
|
||||
numberOfObjects = numberOfPanels + numberOfVariables + numberOfObjects
|
||||
|
@ -222,6 +241,6 @@ async function main(){
|
|||
|
||||
console.log(colors.green.bold(`-------- Have been found ${numberOfObjects} results in ${numberOfDashboards} dashboards -------\n`));
|
||||
|
||||
process.exit(0);
|
||||
process.exit();
|
||||
}
|
||||
main();
|
Loading…
Reference in New Issue