Skip to main content

A tool to parse syslog-like messages into word sequences

Project description

PyPI release Python support BSD 3-Clause License Tests Documentation

Log2seq is a python package to help parsing syslog-like messages into word sequences that is more suitable for further automated analysis. It is based on a procedure customizable with rules in order, using regular expressions.

Installation

You can install log2seq with pip.

pip install log2seq

Tutorial

Log2seq is designed mainly for preprocessing of automated log template generation. Many implementations of template generation methods requires input log messages in segmented format, but they only support simple preprocessing, using white spaces. Log2seq enables more flexible preprocessing enough for parsing practical log messages.

For example, sometimes you may face following format of log messages:

Jan  1 12:34:56 host-device1 system[12345]: host 2001:0db8:1234::1 (interface:eth0) disconnected

This message cannot well segmented with str.split() or re.split(), because the usage of : is not consistent.

log2seq processes this message in multiple steps (in default):

  1. Process message header (i.e., timestamp and source hostname)

  2. Split message body into word sequence by standard symbol strings (e.g., spaces and brackets)

  3. Fix words that should not be splitted later (e.g., ipv6 addr)

  4. Split words by inconsistent symbol strings (e.g., :)

Following is a sample code:

mes = "Jan  1 12:34:56 host-device1 system[12345]: host 2001:0db8:1234::1 (interface:eth0) disconnected"

import log2seq
parser = log2seq.init_parser()

parsed_line = parser.process_line(mes)

Here, you can get the parsed information like:

>>> parsed_line["timestamp"]
datetime.datetime(2020, 1, 1, 12, 34, 56)

>>> parsed_line["host"]
'host-device1'

>>> parsed_line["words"]
['system', '12345', 'host', '2001:0db8:1234::1', 'interface', 'eth0', 'disconnected']

You can see : in IPv6 address is left as is, and other : are removed.

This example is using a default parser, but you can also customize your own parser. For defails, please see the document.

Project details


Download files

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

Source Distribution

log2seq-0.4.1.tar.gz (28.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

log2seq-0.4.1-py3-none-any.whl (23.8 kB view details)

Uploaded Python 3

File details

Details for the file log2seq-0.4.1.tar.gz.

File metadata

  • Download URL: log2seq-0.4.1.tar.gz
  • Upload date:
  • Size: 28.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for log2seq-0.4.1.tar.gz
Algorithm Hash digest
SHA256 d2d2d15f726b115c4d36b93b77cf08ee2eb3a04c1bc9c1f8c7b3db36d19854e7
MD5 5a3ac5c055a74eb1eef4be52ef6e6219
BLAKE2b-256 8535e60b72c519e4d0dccd95a7e5be58821a36d1f0a662336ca4c7edfe9d546f

See more details on using hashes here.

Provenance

The following attestation bundles were made for log2seq-0.4.1.tar.gz:

Publisher: publish.yml on amulog/log2seq

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file log2seq-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: log2seq-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 23.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for log2seq-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0ffbf84993b366da801c136910d4bdc77e87319b6f8e0cde17a5bcc8db9c8ce1
MD5 7797ae932d84c8855a2c4a308a09ce7a
BLAKE2b-256 d228513046eaf87d4c38ee4bdac1abdb0c17583797ef25e244d96a5b30043674

See more details on using hashes here.

Provenance

The following attestation bundles were made for log2seq-0.4.1-py3-none-any.whl:

Publisher: publish.yml on amulog/log2seq

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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