PaaS/Data

Elastic Search API 쿼리 샘플

armyost 2023. 1. 13. 10:05
728x90

참고로 아래 샘플은 Kibana에서 조회한 쿼리로 Elastic Search Server 타겟에 대한 정보는 없습니다.

 

샘플1. apm-.. 라는 인덱스에서 조건에 부합하는 1000개 까지의 콜렉션 조회

GET /apm-*/_search
{
  "from" : 0, "size" :1000,  // 1000개까지의 콜렉션 조회
  "query": {
    "bool" : {
      "must_not": {  // 아래 조건에 부합하지 않는 데이터 조회
        "term" : {
          "host.hostname" : "armyost01server"  // 특정 컬럼에 대한 Value 조건 설정
        }
      },
      "must": {  // 아래 조건에 부합하는 데이터 조회
        "term" : {
          "host.hostname" : "armyost02server"
        }
      }
    }
  }
}

 

 

샘플2. apm-.. 라는 인덱스에서 조건에 부합하면서 최근 하루동안의 1000개 까지의 콜렉션 조회

GET /apm-*/_search
{
  "_source":["host.hostname"],
  "from" : 0,
  "size" :1000,
  "query": {
    "bool" : {
      "must_not": {
        "term" : {
          "host.hostname" : "armyost01server"
        }
      },
      "must": [
        {
          "term" : {
          "host.hostname" : "armyost02server"
          }
        },
        {
          "range": {
            "@timestamp": {
              "gte": "now-1d/d",
              "lte": "now/d"
            }
          }
        }
      ]
    }
  }
}

  

 

'PaaS > Data' 카테고리의 다른 글

ElasticSearch 클러스터 설치하기 3개의 Master, 2개의 Data Node  (0) 2023.08.06
influxDB influx cli 설치하기  (0) 2023.06.26
InfluxDB 설치하기  (0) 2022.10.22
Data Mesh란?  (0) 2022.08.16
Oracle의 Segment Advisor 사용하기  (0) 2022.08.09