Documentation Index

Fetch the complete documentation index at: https://api.ncloud-docs.com/llms.txt

Use this file to discover all available pages before exploring further.

download

Prev Next

概要

Effective Log Search & Analyticsのプロジェクト別ログをダウンロードできます。

リクエスト

API URL

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

リクエストヘッダ

共通の設定に明示されたリクエストヘッダが必要です。

NAVERクラウドプラットフォームの認証キーおよび Signature作成ガイドへ

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

リクエストパラメータ

パラメータ名 必須の有無 タイプ 制限事項 説明
projectKey Yes string 1-53 プロジェクトキー
例: "projectKey":"Pxxxxxx_test"
projectId Yes int Project Id
例: “projectId”:8181
from Yes int 検索を開始するタイムスタンプ(UTC milliseconds).
例: “from”:1381190400000
to No int 検索を終了するタイムスタンプ(UTC milliseconds).
入力しない場合、リクエスト受信時点が自動的に入力されます。
例: “to”:1381190400000
format No string CSV or JSON デフォルト: JSON
ダウンロードするファイル形式
例: “format”: “CSV”
limit No int 1 - 1000 デフォルト: 100
リクエストに対して返すログ数
例:“limit”: 1000
count No int 1 - 200000 デフォルト: 100000
総ダウンロードログ数
例: “count”: 200000
includeFields No [string] デフォルト: すべてのフィールド
ログをダウンロードする際に必要なフィールド名リスト
例: “includeFields”: [“logSource”,” logType”,”body”]

リクエストボディ

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

リクエスト例

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
                  )

レスポンス

レスポンスボディ

application/zip