download
    • PDF

    download

    • PDF

    Article Summary

    概要

    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}
    

    リクエストパラメータ

    パラメータ名必須の有無タイプ制約事項説明
    projectKeyYesstring1-53プロジェクトキー

    例:
    "projectKey":"Pxxxxxx_test"
    projectIdYesintProject Id

    例:
    “projectId”:8181
    fromYesint検索を開始するタイムスタンプ(UTC milliseconds)。

    例:
    “from”:1381190400000
    toYesint検索を終了するタイムスタンプ(UTC milliseconds)。

    例:
    “to”:1381190400000
    formatNostringCSV or JSONデフォルト値:JSON
    ダウンロードするファイル形式。

    例:
    “format”: “CSV”
    limitNoint1 - 1000デフォルト値:100
    リクエストに対して返すログ数です。

    例:「limit」:1000
    countNoint1 - 200000デフォルト値:100000
    総ダウンロードのログ数です。

    例:
    “count”: 200000
    includeFieldsNo[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
    }
    

    リクエスト例<a name=リクエスト例">

    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
    

    この記事は役に立ちましたか?

    What's Next
    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.