Skip to content
python humio adapter
Python
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples
humio_api
img
.gitignore
MANIFEST.in
README.md
setup.py

README.md

Python Humio library

This is still in early development. If you find something missing create an issue or contact us via community.humio.com and let us know.

Documentation for our API can be found here.

Example scripts

See the "examples" folder

run query script example

Query examples

from humio_api.humio_api import HumioApi

# Init the API
api = HumioApi(baseUrl='https://cloud.humio.com', repo='<YOUR_REPO>',
               token='<YOUR_TOKEN>')

# creating query
initQueryRes = api.initQuery(queryString='timechart()')
# getting query result
if initQueryRes.status_code == 200:
    queryId = initQueryRes.json()['id']
    res = api.getQueryResult(queryId)
    # printing json
    if res.status_code == 200:
        HumioApi.prettyPrintJson(res.json())

User management examples (only for local on prem install)

from humio_api.humio_api import HumioApi

# Init the API
h = HumioApi(baseUrl='https://cloud.humio.com', repo='<YOUR_REPO>',
             token='<YOUR_TOKEN>')

# Get all users
users = h.getUserList()

# Pretty print users list
HumioApi.prettyPrintJson(users)

# Get user by email
user = h.getUserByEmail('some@email.com')

# Pretty print user details
HumioApi.prettyPrintJson(user)

# Create user
api.createUser('some@email.com')

Data ingest examples

from humio_api.humio_api import HumioApi

# Init the API
h = HumioApi(baseUrl='https://cloud.humio.com', repo='<YOUR_REPO>',
             token='<YOUR_TOKEN>')

# some test data
jsonDt=[
    {
        "tags": {
            "host": "server1",
            "source": "application.log"
        },
        "events": [
            {
                "timestamp": "2016-06-06T12:00:00+02:00",
                "attributes": {
                    "key1": "value1",
                    "key2": "value2"
                }
            },
            {
                "timestamp": "2016-06-06T12:00:01+02:00",
                "attributes": {
                    "key1": "value1"
                }
            }
        ]
    }
]

# Ingesting the data
h.ingestJsonData(jsonDt)
You can’t perform that action at this time.