metrics-migration
a simple tool to help you migrate your graphite metrics
What is metrics-migration ?
metrics-migration a Python3 tool (async io), designed to help graphite users to migrate metrics in several ways.
Migrate whole storage directory.
Migrate specific whisper file (with new metric name).
Allow schema change during Migration (Provide schema rule).
Install
You can install aiographite globally with any Python package manager:
pip3 install metrics-migration
Dependency
Whisper on pypi only supports python2, we should download whisper egg from github.
pip3 install https://github.com/graphite-project/whisper/tarball/feature/py3
Examples
Let’s get started with several examples.
Example 1. A simple example to migrate a directory.
from migration.migration import Migration
import asyncio
loop = asyncio.get_event_loop()
host = "127.0.0.1"
port = 2003
directory = '/Users/yunx/Documents/PROJECTS/metrics-migration/examples'
async def go():
migration_worker = Migration(directory, host, port, loop=loop)
await migration_worker.connect_to_graphite()
await migration_worker.run()
await migration_worker.close_conn_to_graphite()
def main():
loop.run_until_complete(go())
loop.close()
if __name__ == '__main__':
main()
Example 2. Migrate a whipser file with new metric.
from migration.migration import Migration
import asyncio
loop = asyncio.get_event_loop()
host = "127.0.0.1"
port = 2003
directory = '/Users/yunx/Documents/PROJECTS/metrics-migration/examples'
storage_dir = '/Users/yunx/Documents/PROJECTS/metrics-migration'
metric = "examples.committedPoints"
new_metric = 'hello.world'
async def go():
migration_worker = Migration(directory, host, port, loop=loop, debug=True)
await migration_worker.connect_to_graphite()
await migration_worker.send_one_wsp(storage_dir, metric, new_metric)
await migration_worker.close_conn_to_graphite()
def main():
loop.run_until_complete(go())
loop.close()
if __name__ == '__main__':
main()
Example 3. Have Multiple Directories to migrate ?
from migration.migration import Migration
import asyncio
loop = asyncio.get_event_loop()
host = "127.0.0.1"
port = 2003
directories_and_prefixes = [
('/opt/graphite/metrics-migration/zon1', 'zon1'),
('/opt/graphite/metrics-migration/zon2', 'zon2'),
]
async def go():
migration_worker = Migration(directory, host, port, loop=loop)
await migration_worker.connect_to_graphite()
for (directory, prefix) in directories_and_prefixes:
wait migration_worker.run(directory=directory, prefix=prefix)
await migration_worker.run()
await migration_worker.close_conn_to_graphite()
def main():
loop.run_until_complete(go())
loop.close()
if __name__ == '__main__':
main()
Example 4. async with context manager
from migration.migration import Migration
import asyncio
loop = asyncio.get_event_loop()
host = "127.0.0.1"
port = 2003
directory = '/Users/yunx/Documents/PROJECTS/metrics-migration/examples'
async def go():
"""
Use context manager
"""
async with Migration(directory, host, port, loop=loop, debug=True) as migration_worker:
await migration_worker.run()
def main():
loop.run_until_complete(go())
loop.close()
if __name__ == '__main__':
main()
Development
Run unit tests.
./uranium test
Metadata
Release files for metrics-migration 0.1.2
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 | Actions |
|---|---|---|---|---|
| metrics-migration-0.1.2.tar.gz | 5.2 kB | Without provenance | Details for metrics-migration-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| metrics_migration-0.1.2-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for metrics_migration-0.1.2-py2.py3-none-any.whl |
Total release size: 13.5 kB
Release files / metrics-migration-0.1.2.tar.gz
| Download URL | metrics-migration-0.1.2.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f71ff393410074ca0a1be215b1d37edd5ec0ef36d80ab45e5380045732c15198
|
|
BLAKE2b-256 checksum How to use checksums |
537998d86ead314592c060efd5b283351a3f1abb50154f803a56c21e1e724b48
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / metrics_migration-0.1.2-py2.py3-none-any.whl
| Download URL | metrics_migration-0.1.2-py2.py3-none-any.whl |
|---|---|
| Size | 8.3 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
447d650d5a9b8013b2a7cfd7c3d3f80ff8df0a9d68672abdd5b67f8b5f9cad34
|
|
BLAKE2b-256 checksum How to use checksums |
eef41016d836ecec3482dc7149df082dd72f94fcfb1529769951cfac95139bac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for metrics-migration 0.1.2
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.