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 headers

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
e.g., "projectKey":"Pxxxxxx_test"
projectId Yes int Project ID
e.g., "projectId":8181
from Yes int Timestamp at which to start the search (UTC milliseconds)
e.g., "from":1381190400000
to No int Timestamp at which to end the search (UTC milliseconds)
If not entered, the time the request was received will be entered automatically.
e.g., "to":1381190400000
format No string CSV or JSON Default: JSON
File format to download
e.g., "format": "CSV"
limit No int 1 - 1000 Default: 100
Number of logs to return upon request
e.g., "limit":1000
count No int 1 - 200000 Default: 100000
Total download log count
e.g., "count": 200000
includeFields No [string] Default: All fields
List of field names required when downloading logs
e.g., "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 example

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