Query API

개요

  • IRIS Discovery Service 에 검색 명령어를 통해 분석 결과를 도출 하는 API

Fetch SID

URL

  • /angora/query/jobs

Method

  • POST

Description

  • 처음 검색을 하기 위해서 session ID가 필요합니다. 이를 가져오는 API 입니다. 질의에 필요한 각종 parameters 를 함께 넘겨 주어야 합니다.

Parameters

fetch_size

  • 예제
    1. size = 500, fetch_size = 1 -> 500 * 1 = 500 개의 데이터 반환
    2. size = 500, fetch_size = 10 -> 500 * 10 = 5000 개의 데이터 반환

dataset Parameters

option

Example

  • Request
curl -XPOST "http://localhost:6036/angora/query/jobs"
    -H "Authorization: Angora bXktb3JnLW5hbWU6MTIza2V5NGFwaQ=="
    -H "Content-Type: application/json"
    -d '{
        "q" : "model name = syslog start_date = 20191104130300 end_date = 20191104130400 | stats count(*) by datetime",
        "size" : 500,
        "fetch_size" : 10
    }'
  • Response
{
    "sid" : 1461649586.1695
}
  • Exception
{
    "type": "RuntimeError",
    "message": "This was failed because..."
}

Fetch Results

URL

  • /angora/query/jobs/[sid]

Method

  • GET

Description

  • 질의한 결과를 가져옵니다.

Example

  • Request
curl -XGET "http://localhost:6036/angora/query/jobs/1461649586.1695"
    -H "Authorization: Angora bXktb3JnLW5hbWU6MTIza2V5NGFwaQ=="
  • Response
{
    "status": {
        "current" : 0,
        "total" : 5000
    },
    "isEnd" : true,
    "fields": [
        {
            "name": "DATETIME",
            "type": "string"
        },
        {
            "name": "count(*)",
            "type": "number"
        }
    ],
    "results": [
        ["20180827170300", 5],
        ["20180827171405", 19]
        ...
    ]
}
  • Exception
{
    "type": "RuntimeError",
    "message": "This was failed because..."
}

Downloads Results

URL

  • /angora/query/jobs/[sid]/download?type=[csv|json]&sep=,&file_name=test

Method

  • GET

Description

  • 질의한 결과를 streaming으로 해당 type 형태에 맞게 반환합니다.
  • typecsv/tsv/json 을 지원합니다. sepcsv 의 경우, 필드 구분자(, , | 등)를 의미합니다.

Example

  • Request (json)
curl -XGET "http://localhost:6036/angora/query/jobs/1461649586.1695/download?type=json"
    -H "Authorization: Angora bXktb3JnLW5hbWU6MTIza2V5NGFwaQ=="
  • Response (json)
{
    "fields": [
        {
            "name": "fieldA",
            "type": "string"
        },
        {
            "name": "fieldB",
            "type": "number"
        }
    ],
    "results": [
        {"fieldA" : "a", "fieldB": 1},
        {"fieldA" : "c", "fieldB": 3}
    ]
}
  • Request (csv)
curl -XGET "http://localhost:6036/angora/query/jobs/1461649586.1695/download?type=csv"
    -H "Authorization: Angora bXktb3JnLW5hbWU6MTIza2V5NGFwaQ=="
  • Response (csv)
fieldA,fieldB
a,2
c,3
  • Exception
{
    "type": "RuntimeError",
    "message": "This was failed because..."
}

Export Results

URL

  • /angora/query/jobs/[sid]/export

Method

  • GET

Description

  • 질의한 결과를 시초에 POST에 셋업되있는 arguments 형태에 맞게 저장합니다.

Example

  • Request
curl -XGET "http://localhost:6036/angora/query/jobs/1461649586.1695/export"
    -H "Authorization: Angora bXktb3JnLW5hbWU6MTIza2V5NGFwaQ=="
  • Response
{
    "message" : "OK"
}
  • Exception
{
    "type": "RuntimeError",
    "message": "This was failed because..."
}

Abort (Close Jobs)

URL

  • /angora/query/jobs/[sid]/close

Method

  • DELETE

Description

  • 검색 중인 session을 종료 합니다.
  • 일정 시간이 지날동안 해당 session의 응답이 없으면 자동으로 종료되나, 종료가 예상되는 경우에는 직접 종료해주어야 합니다.

Example

  • Request
curl -XDELETE "http://localhost:6036/angora/query/jobs/1461649586.1695/close"
    -H "Authorization: Angora bXktb3JnLW5hbWU6MTIza2V5NGFwaQ=="
  • Response
{
    "sid": 1461649586.1695
}
  • Exception
{
    "type": "RuntimeError",
    "message": "This was failed because..."
}