mackerel.client is a python library to access Mackerel (https://mackerel.io/).
This client is Ported from mackerel-client-ruby.
Install
$ pip install mackerel.client
Dependency
mackerel.client use requests, simplejson and click.
Usage
Get hosts
from mackerel.client import Client
client = Client(mackerel_api_key='<Put your API key')
host = client.get_hosts()
Get host
from mackerel.client import Client
client = Client(mackerel_api_key='<Put your API key')
host = client.get_host('<hostId>')
Update host status
from mackerel.client import Client
client = Client(mackerel_api_key='<Put your API key')
# Poweroff.
self.client.update_host_status('<hostId>', 'poweroff')
# Standby.
self.client.update_host_status('<hostId>', 'standby')
# Working.
self.client.update_host_status('<hostId>', 'working')
# Maintenance.
self.client.update_host_status('<hostId>', 'maintenance')
Retire host
from mackerel.client import Client
client = Client(mackerel_api_key='<Put your API key')
self.client.retire_host('<hostId>')
Get latest metrics
from mackerel.client import Client
client = Client(mackerel_api_key='<Put your API key')
# Get hostId A's and hostId B's loadavg5, memory.free value.
metrics = self.client.get_latest_metrics(['<hostId A>', '<hostId B>'],
['loadavg5', 'memory.free'])
Post metrics
from mackerel.client import Client
client = Client(mackerel_api_key='<Put your API key>')
metrics = [
{
'hostId': '<hostId>', 'name': 'custom.metrics.loadavg',
'time': 1401537844, 'value': 1.4
},
{
'hostId': '<hostId>', 'name': 'custom.metrics.uptime',
'time': 1401537844, 'value': 500
}
]
# Post `custom.metrics.loadavg` and `custom.metrics.uptime` to `hostId`.
client.post_metrics(metrics)
Post service metrics
from mackerel.client import Client
client = Client(mackerel_api_key='<Put your API key>')
metrics = [
{
'name': 'custom.metrics.latency',
'time': 1401537844, 'value': 0.5
},
{
'name': 'custom.metrics.uptime',
'time': 1401537844, 'value': 500
}
]
# Post 'custom.metrics.latency' and 'custom.metrics.uptime' to `service_name`.
self.client.post_service_metrics('service_name', metrics)
CLI
Get host(s) information from hostname or service, role.
$ mkr.py info [--name foo] [--service service] [--role role]
Set status of a host.
$ mkr.py status --host-id foo --status working
Retire a host.
$ mkr.py retire --host-id foo
Get status of a host.
$ mkr.py status --host-id foo
Authentication
$ export MACKEREL_APIKEY=foobar
Metadata
Release files for mackerel.client 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| mackerel.client-0.2.1.tar.gz | 6.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mackerel.client-0.2.1-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 14.3 kB
Release files / mackerel.client-0.2.1.tar.gz
| Download URL | mackerel.client-0.2.1.tar.gz |
|---|---|
| Size | 6.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
665220ec311718a37b4594e21c9aede05c3adf53ce29981e6f9f05bee0ca2ebc
|
|
BLAKE2b-256 checksum How to use checksums |
2bdbe84a04f19e8eb6a9091c06667039ba5381c70c5bfe9b8b1cd09f2719d864
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.4
|
Release files / mackerel.client-0.2.1-py2.py3-none-any.whl
| Download URL | mackerel.client-0.2.1-py2.py3-none-any.whl |
|---|---|
| Size | 8.0 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
376138f053aaeaf98ac48b94c001c610f282e9074ef6bd1185245a0ee655bdb3
|
|
BLAKE2b-256 checksum How to use checksums |
df01ad6c1d822103e2f25cf41089a9c9ab0bd4f80cdcf3f0a79ae1edd21d52ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.4
|
Security for mackerel.client 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.