download

Prev Next

Overview

You can download Effective Log Search & Analytics logs by project.

Request

API URL

POST
https://elsa.apigw.ntruss.com/api/v1/logs/download

Request header

The request headers specified in common settings are required.

Go to the creation guide of NAVER Cloud Platform authentication key and signature

x-ncp-apigw-timestamp: {current timestamp}
x-ncp-iam-access-key: {your iam access key}
x-ncp-apigw-signature-v2: {generated signature}

Request parameter

Parameter name Requirement status Type Restrictions Description
projectKey Yes string 1-53 Project key

Example:
"projectKey":"Pxxxxxx_test"
projectId Yes int Project Id

Example:
“projectId”:8181
from Yes int The timestamp at which to start the search (UTC milliseconds).

Example:
“from”:1381190400000
to Yes int The timestamp at which to end the search (UTC milliseconds).

Example:
“to”:1381190400000
format No string CSV or JSON Default: JSON
File format to download.

Example:
“format”: “CSV”
limit No int 1 - 1000 Default: 100
This is the number of logs to return upon request.

Example:"limit": 1000
count No int 1 - 200000 Default: 100000
The total number of log downloads.

Example:
“count”: 200000
includeFields No [string] Default value: all fields
This is the list of field names needed to download logs.

Example:
“includeFields”: [“logSource”,” logType”,”body”]

Request body

{
  "projectKey": "Pbxxxxx_elsa-test",
  "projectId": 16706,
  "from": 1381190400000,
  "to": 1381190400000,
  "format": "JSON",
  "includeFields": ["logSource","logType","ExceptionType"],
  "limit": 100,
  "count": 50000
}

Request examples

import hashlib
import hmac
import base64
import time
import requests

def make_signature(access_key, secret_key, timestamp, url):
    timestamp = str(timestamp)
    secret_key = bytes(secret_key, 'UTF-8')
    method = "POST"

    message = method + " " + url + "\n" + timestamp + "\n" + access_key
    message = bytes(message, 'UTF-8')
    signingKey = base64.b64encode(hmac.new(secret_key, message, digestmod=hashlib.sha256).digest())
    return signingKey.decode('UTF-8')


def log_download():
    baseurl = "https://elsa.apigw.ntruss.com" #{OpenAPI endpoint}
    url = "/api/v1​/logs​/download"

    access_key = "accessKey" #{Main / Sub Account Access Key}
    secret_key = "secretKey" #{Main / Sub Account Secret Key}
    timestamp = int(time.time() * 1000)

    signature = make_signature(access_key, secret_key, timestamp, url)
    url = baseurl + url

    payload = 	{
	  "projectKey": "Pbxxxxx_elsa-test",
	  "projectId": 8171,
	  "format": "JSON",
	  "from": 1381190400000,
	  "to": 1381190400000,
	  "includeFields": ["logSource","logType","ExceptionType"],
	  "limit": 100,
	  "count": 50000
	}


    headers = {
        "x-ncp-apigw-timestamp": str(timestamp),
        "x-ncp-iam-access-key": access_key,
        "x-ncp-apigw-signature-v2": str(signature)
    }

    response = requests.post(url=url,
                  json=payload,
                  verify=True,
                  headers=headers
                  )

Response

Response body

application/zip