Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

139
Visualizações
how do i check if hits has a value or not?

My goal is to send an alarm if the [hits] field is empty.

This is my result:

hits: {
 total: { value: 10000, relation: 'gte' },
 max_score: 1,
 hits: [
   [Object], [Object],
   [Object], [Object],
   [Object], [Object],
   [Object], [Object],
   [Object], [Object]
 ]
 }
}

and this is my code:

const axios = require('axios');
const query = {
query: {
match: {
 "kubernetes.pod.name.keyword" : "fcppaddy-596b798c77-9hwbh"
      }
     }
    };
 axios.get("https://tommaso.fachin:Indigestione!@elastic.gnet.it:9200/filebeat-7.15.2/_search? 
 pretty", query)
  .then((res) => {
    console.log(res.data);
    console.log(res.status);
console.log(JSON.stringify(res.data));
  });
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I'm still not 100%, but from your comments it seems like you want to check if hits has anything in it, and if so do something for each one:

if(hits.length > 0) {
  hits.forEach((hit) => {
    triggerAlarm()
  })
}

So obviously you can choose what to send as a param to triggerAlarm() but I think this is what you're asking for

Edit, based on your comment:

if(hits.hits.length > 0) {
  hits.forEach((hit) => {
    // for each item in hits.hits array, send mail
    ModuloMail()
  })
}
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda