Skip to main content

Package to count usage statistics from ELK logs.

Project description

Vuakhter

Build Status Maintainability Test Coverage PyPI version PyPI - Python Version

Vuakhter is validation tool to test API to conform our API guide. But it can be used to generate statistics of web-application by its logs.

Principles of work

Vuakhter scans access log for specified period, filters log entries by path prefixes and passes each entry for statistics generation.

Base class AccessLog returns an iterator of log entries. Class ElasticAccessLog scans elastic indices for log entries.

StatisticsMetrics gets AccessEntry records and forms array of statistics data. StatisticsMetrics.report() -> str returns statistics report for the metrics.

HttpAnalyzer uses access_log: AccessLog and array of StatisticsMetrics.

Only one metric SchemaValidatorCounter is passing to HttpAnalyzer in main script vuakhter. It uses request_log: RequestLog to validate API responses.

Class ElasticRequestLog: RequestLog scans elastic indices requests by request_id and returns array of RequestEntry. SchemaValidatorCounter checks all responses bodies and counts valid API calls.

Installation

pip install vuakhter

Usage

vuakhter [--es-user ES_USER] [--es-pass ES_PASS] [--es-host ES_HOST] [--es-port ES_PORT
[--start-date START_DATE] [--end-date END_DATE] prefixes [prefixes ...]

By default end_date is current date and time if not specified. And start_date defaults to day ago end_date.

All connection parameters may be specified in .env file.

ES_USER=elastic ES_PASS=pasword ES_HOST=localhost vuakhter /api/

Using in code

import datetime

from elasticsearch import Elasticsearch

from vuakhter.analyzer import HttpAnalyzer
from vuakhter.kibana.access_log import ElasticAccessLog
from vuakhter.metrics.counters import ComplexCounter


elastic = Elasticsearch()
access_log = ElasticAccessLog(index_pattern='filebeat-*', client=elastic)

http_analyzer = HttpAnalyzer(access_log=access_log)
http_analyzer.add_metrics(ComplexCounter())

end_date = datetime.datetime.now()
start_date = end_date - datetime.timedelta(days=1)

http_analyzer.analyze(start_date, end_date)

for metric in http_analyzer.metrics:
    metric.finalize()
    print(metric.report())

Contributing

We would love you to contribute to our project. It's simple:

  • Create an issue with bug you found or proposal you have. Wait for approve from maintainer.
  • Create a pull request. Make sure all checks are green.
  • Fix review comments if any.
  • Be awesome.

Here are useful tips:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

vuakhter-0.0.5-py3-none-any.whl (23.5 kB view details)

Uploaded Python 3

File details

Details for the file vuakhter-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: vuakhter-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 23.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.5

File hashes

Hashes for vuakhter-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 9b2de5d9ad40b6295a7777d0965f78e8f080cf1f41026511e6d1489b7e5cfda3
MD5 50f649741327c6bb6d03bd4758af6128
BLAKE2b-256 ac5efea221f8cbd5e0bba89662dd5e3fc7302d0a6714088d8f812575a9a631c0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page