Follow

Get Logs

Description

This API downloads a ZIP with the log files generated by the test and also the files used in the session which includes the JMX, the CSVs used and external JARs if uploaded initially.
This function includes parameters to identify both the user and the session.

API v4

URL

https://a.blazemeter.com:443/api/v4/sessions/sessionID/reports/logs

Request Parameters

Parameter Description
API Key Identifies the user ( --user 'id:secret' ) . How to get the API Key?
Session ID Identifies the Session. How to get the Session ID?

cURL

wget 'curl https://a.blazemeter.com/api/v4/sessions/<sessionID>/reports/logs -H "Content-Type: application/json" | jq '.result.data[] | select(.title=="Zip") | .dataUrl' | tr -d '""'' --user 'id:secret'

Python

import requests
import json	
import urllib2

def JTLsWget(session_id):
	return requests.get('https://a.blazemeter.com/api/latest/sessions/{0}/reports/logs/'.format(session_id), auth=('id','secret')) 

res = JTLsWget("<sessionID>")
print res.json()

Json_String = res.json()
url = [entry for entry in Json_String['result']['data'] if entry['filename'] == 'jtls_and_more.zip'][0]['dataUrl']
print url
open('jtls_and_more.zip', 'wb').write(urllib2.urlopen(url).read())

Example Response

{
    "result": {
        "hash": "logs",
        "name": "Logs",
        "data": [
            {
                "tailDataUrl": "https://blazemeter.s3.amazonaws.com/users/67295/tests/5019049/reports/r-op-beta54ad51d55b738/jmeter-console0.log.tail.bz?AWSAccessKeyId=AKIAJPZOF6U7I33QK2CQ&Expires=1433260243&Signature=%2FXTamPKLEEQsFKtOj3izuBopD7Q%3D",
                "filename": "jmeter-console0.log",
                "dataUrl": "https://blazemeter.s3.amazonaws.com/users/67295/tests/5019049/reports/r-op-beta54ad51d55b738/jmeter-console0.log?AWSAccessKeyId=AKIAJPZOF6U7I33QK2CQ&Expires=1433260243&Signature=6qMBsPt%2FPsL%2BPQR8W5u0vXcmpDU%3D",
                "title": "jmeter-console0"
            },
            {
                "tailDataUrl": "False",
                "filename": "jtls_and_more.zip",
                "dataUrl": "https://blazemeter.s3.amazonaws.com/users/67295/tests/5019049/reports/r-op-beta54ad51d55b738/jtls_and_more.zip?AWSAccessKeyId=AKIAJPZOF6U7I33QK2CQ&Expires=1433260243&Signature=XCa4kapJWIfa0Z5JXeGesqg751w%3D",
                "title": "Zip"
            }
        ],
        "session_id": "r-op-beta54ad51d55b738",
        "source": "",
        "dataUrl": "https://a.blazemeter.com/api/latest/sessions/r-op-beta54ad51d55b738/reports/logs/data",
        "type": "Logs",
        "id": "logs"
    },
    "api_version": 2,
    "error": "None"
}

 

API v2

URL

https://a.blazemeter.com:443/api/v4/sessions/sessionID/reports/logs

Request Parameters

Parameter Description
Api Key Identifies the user. How to get the API Key?
Session ID Identifies the Session. How to get the Session ID?

cURL

wget `curl https://a.blazemeter.com/api/latest/sessions/<sessionID>/reports/logs -H "Content-Type: application/json" -H "x-api-key: 62f7f52eb342c3ec1e31" | jq '.result.data[] | select(.title=="Zip") | .dataUrl' | tr -d '""'`

Python

import requests
import json	
import urllib2

def JTLsWget(session_id):
	return requests.get('https://a.blazemeter.com/api/latest/sessions/{0}/reports/logs/'.format(session_id), headers={"x-api-key": ";65f7f52eb362c4ec2e31"}) 

res = JTLsWget("<sessionID>")
print res.json()

Json_String = res.json()
url = [entry for entry in Json_String['result']['data'] if entry['filename'] == 'jtls_and_more.zip'][0]['dataUrl']
print url
open('jtls_and_more.zip', 'wb').write(urllib2.urlopen(url).read())

Example Response

{
    "result": {
        "hash": "logs",
        "name": "Logs",
        "data": [
            {
                "tailDataUrl": "https://blazemeter.s3.amazonaws.com/users/67295/tests/5019049/reports/r-op-beta54ad51d55b738/jmeter-console0.log.tail.bz?AWSAccessKeyId=AKIAJPZOF6U7I33QK2CQ&Expires=1433260243&Signature=%2FXTamPKLEEQsFKtOj3izuBopD7Q%3D",
                "filename": "jmeter-console0.log",
                "dataUrl": "https://blazemeter.s3.amazonaws.com/users/67295/tests/5019049/reports/r-op-beta54ad51d55b738/jmeter-console0.log?AWSAccessKeyId=AKIAJPZOF6U7I33QK2CQ&Expires=1433260243&Signature=6qMBsPt%2FPsL%2BPQR8W5u0vXcmpDU%3D",
                "title": "jmeter-console0"
            },
            {
                "tailDataUrl": "False",
                "filename": "jtls_and_more.zip",
                "dataUrl": "https://blazemeter.s3.amazonaws.com/users/67295/tests/5019049/reports/r-op-beta54ad51d55b738/jtls_and_more.zip?AWSAccessKeyId=AKIAJPZOF6U7I33QK2CQ&Expires=1433260243&Signature=XCa4kapJWIfa0Z5JXeGesqg751w%3D",
                "title": "Zip"
            }
        ],
        "session_id": "r-op-beta54ad51d55b738",
        "source": "",
        "dataUrl": "https://a.blazemeter.com/api/latest/sessions/r-op-beta54ad51d55b738/reports/logs/data",
        "type": "Logs",
        "id": "logs"
    },
    "api_version": 2,
    "error": "None"
}

;;

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.