Python

LogHive provides a simple REST API that you can use to push events and errors. Here is an example code for Python:

Push Event

import requests
import json

url = "https://api.loghive.app/v1/event/add"
headers = {'Content-Type': 'application/json', 'ApiKey': 'YourPersonalApiKey'}
data = { "project": "yourprojectname","group": "yourgroupname","event": "your-event-name", "description": "your-description", "notify": False }
response = requests.post(url, headers=headers, data=json.dumps(data))

print(response.status_code)
if response.status_code != 200:
    print(response.json())

Push Insight

import requests
import json

url = "https://api.loghive.app/v1/insight/add"
headers = {'Content-Type': 'application/json', 'ApiKey': 'YourPersonalApiKey'}
data = { "project": "yourprojectname","insight": "yourinsightname","value": 100 }
response = requests.post(url, headers=headers, data=json.dumps(data))

print(response.status_code)
if response.status_code != 200:
    print(response.json())

Set Online/Offline

import requests
import json

url = "https://api.loghive.app/v1/insight/add"
headers = {'Content-Type': 'application/json', 'ApiKey': 'YourPersonalApiKey'}

# set online
data = { "project": "yourprojectname","insight": "system1","value": 1 }
response = requests.post(url, headers=headers, data=json.dumps(data))

# set offline
data = { "project": "yourprojectname","insight": "system1","value": 0 }
response = requests.post(url, headers=headers, data=json.dumps(data))

print(response.status_code)
if response.status_code != 200:
    print(response.json())

Last updated