All Projects → shuLhan → haminer

shuLhan / haminer

Licence: GPL-3.0 license
[mirror] Library and program to parse and forward HAProxy HTTP logs

Programming Languages

go
31211 projects - #10 most used programming language
shell
77523 projects
Makefile
30231 projects

Projects that are alternatives of or similar to haminer

archi cloudnative
Cloud Native Architectural Models using Archi. Contains models for CAAS, Cloud Native Applications, 12/15 Factor Applications with CI/CD/CS, monitoring and log management. Infrastructure components include Red Hat OpenShift, Red Hat Storage, Red Hat Ansible Tower, Red Hat Cloudforms, Red Hat Satellite, Red Hat JBoss Middleware.
Stars: ✭ 55 (+150%)
Mutual labels:  log, haproxy
Haproxy Configs
80+ HAProxy Configs for Hadoop, Big Data, NoSQL, Docker, Elasticsearch, SolrCloud, HBase, MySQL, PostgreSQL, Apache Drill, Hive, Presto, Impala, Hue, ZooKeeper, SSH, RabbitMQ, Redis, Riak, Cloudera, OpenTSDB, InfluxDB, Prometheus, Kibana, Graphite, Rancher etc.
Stars: ✭ 106 (+381.82%)
Mutual labels:  influxdb, haproxy
Quicklogger
Library for logging on files, console, memory, email, rest, eventlog, syslog, slack, telegram, redis, logstash, elasticsearch, influxdb, graylog, Sentry, Twilio, ide debug messages and throw events for Delphi/Firemonkey/freepascal/.NET (Windows/Linux/OSX/IOS/Android).
Stars: ✭ 137 (+522.73%)
Mutual labels:  influxdb, log
fakessh
A dockerized fake SSH server honeypot written in Go that logs login attempts.
Stars: ✭ 42 (+90.91%)
Mutual labels:  log
logtail
logtail is a log tailing utility, support tailing multiple commands output stream, transferring matching content to file/webhook(like dingtalk)
Stars: ✭ 33 (+50%)
Mutual labels:  log
influx4mqtt
Insert incoming MQTT values into InfluxDB. Follows mqtt-smarthome architecture.
Stars: ✭ 34 (+54.55%)
Mutual labels:  influxdb
scavenger
A fast Burstcoin miner written in Rust
Stars: ✭ 105 (+377.27%)
Mutual labels:  miner
loggie
A lightweight, cloud-native data transfer agent and aggregator
Stars: ✭ 844 (+3736.36%)
Mutual labels:  log
influxdb-client-ruby
InfluxDB 2.0 Ruby Client
Stars: ✭ 30 (+36.36%)
Mutual labels:  influxdb
kuafu
This is a tool library that includes log, fsm, state machine...
Stars: ✭ 83 (+277.27%)
Mutual labels:  log
dagger
Dagger is an easy-to-use, configuration over code, cloud-native framework built on top of Apache Flink for stateful processing of real-time streaming data.
Stars: ✭ 238 (+981.82%)
Mutual labels:  influxdb
tracker
Track your activities!
Stars: ✭ 14 (-36.36%)
Mutual labels:  influxdb
Architeuthis
MITM HTTP(S) proxy with integrated load-balancing, rate-limiting and error handling. Built for automated web scraping.
Stars: ✭ 35 (+59.09%)
Mutual labels:  influxdb
Klog
🎼 A Kotlin log lib, making the output log more elegant and more beautiful.
Stars: ✭ 21 (-4.55%)
Mutual labels:  log
bk-log
蓝鲸日志平台是为了解决运维场景中查询日志难的问题而推出的一款SaaS,基于业界主流的全文检索引擎,通过蓝鲸智云的专属agent进行日志采集,无需登录各台机器,集中管理所有日志。
Stars: ✭ 102 (+363.64%)
Mutual labels:  log
RFKit
Toolkit for daily Cocoa development. Since 2012.
Stars: ✭ 20 (-9.09%)
Mutual labels:  log
log-target-file
Yii Logging Library - File Target
Stars: ✭ 19 (-13.64%)
Mutual labels:  log
log-master
split the log
Stars: ✭ 28 (+27.27%)
Mutual labels:  log
docker-iot-dashboard
A complete IoT server for LoRaWAN IoT projects: node-red + influxdb + grafana + ssl + let's encrypt using docker-compose.
Stars: ✭ 79 (+259.09%)
Mutual labels:  influxdb
BuildTimeLogger-for-Xcode
A console app for logging Xcode build times and presenting them in a notification
Stars: ✭ 43 (+95.45%)
Mutual labels:  log

haminer

Library and program to parse and forward HAProxy logs.

The HTTP logs is HTTP request that received by HAProxy frontend and forwarded to backend. In default format, it looks like these (split into multi lines, for readability):

<158>Sep  4 17:08:47 haproxy[109530]: 185.83.144.103:46376
  [04/Sep/2022:17:08:47.264] www~ be_kilabit/kilabit-0.0/0/1/2/3 200 89 - -
  ---- 5/5/0/0/0 0/0 "GET / HTTP/1.1"

See HTTP log format documentation for more information.

Currently, there are two supported database where haminer can forward the parsed log: influxdb and questdb. Haminer support Influxdb v1 and v2.

 +---------+  UDP  +---------+      +-----------+
 | HAProxy |------>| haminer |----->| influxdb  |
 +---------+       +---------+      | / questdb |
                                    +-----------+

In Influxdb, the log are stored as measurement called haproxy. In Questdb, the log are stored as table called haproxy.

The following fields are stored as tags (in Influxdb) or symbol (in Questdb): host, server, backend, frontend, http_method, http_url, http_query, http_proto, http_status, term_state, client_ip, client_port.

And the following fields are stored as fields (in Influxdb) or values (in Questdb): time_req, time_wait, time_connect, time_rsp, time_all, conn_active, conn_frontend, conn_backend, conn_server, conn_retries, queue_server, queue_backend, bytes_read.

Once the log has been accumulated, we can query the data. For example, with Questdb we can count each visited URL using the following query,

select backend, http_url, count(*) as visit from 'haproxy'
group by backend, http_url
order by visit desc;

Installation

Building from source

Requirements

  • Go for building from source code

  • git for downloading source code

Get the source code using git,

$ git clone https://git.sr.ht/~shulhan/haminer
$ cd haminer
$ make

The binary name is haminer build in the current directory.

Pre-build package

The Arch Linux package is available at build.kilabit.info. Add the following repository to your pacman.conf,

[build.kilabit.info]
Server = https://build.kilabit.info/aur

To install it,

$ sudo pacman -Sy --noconfirm haminer-git

Configuration

haminer by default will load it’s config from /etc/haminer.conf, if not specified when running the program.

See haminer.conf for an example of possible configuration and their explanation.

Forwarders

Currently, there are two supported database where haminer can forward the parsed log: influxdb and questdb. Haminer support Influxdb v1 and v2.

Influxdb v1

For v1, you need to create the user and database first,

$ influx
> CREATE USER "haminer" WITH PASSWORD 'haminer'
> CREATE DATABASE haminer
> GRANT ALL ON haminer TO haminer

Example of forwarder configuration,

[forwarder "influxd"]
version = v1
url = http://127.0.0.1:8086
bucket = haminer
user = haminer
password  = haminer

Influxdb v2

For v2,

$ sudo influx bucket create \
	--name haminer \
	--retention 30d

For v2, the example configuration is

[forwarder "influxd"]
version = v1
url = http://127.0.0.1:8086
org = $org
bucket = haminer
token = $token

Questdb

For questdb the configuration is quite simple,

[forwarder "questdb"]
url = udp://127.0.0.1:9009

We did not need to create the table, questdb will handled that automatically.

Deployment

  1. Copy configuration from $SOURCE/cmd/haminer/haminer/conf to /etc/haminer.conf

  2. Update haminer configuration in /etc/haminer.conf

    For example,

    [haminer]
    listen = 127.0.0.1:5140
    
    ...

    Add one or more provider to the configuration as the example above.

  3. Update HAProxy config to forward log to UDP port other than rsyslog.

    For example,

    global
    	...
    	log 127.0.0.1:5140 local3
    	...

    Then reload or restart HAProxy.

  4. Run the haminer program,

    $ haminer

    or use a systemd service.

    $ sudo systemctl enable haminer
    $ sudo systemctl start  haminer

License

haminer - Library and program to parse and forward HAProxy logs.
Copyright (C) 2018-2022 M. Shulhan <[email protected]>

This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or any later version.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
details.

You should have received a copy of the GNU General Public License along with
this program.
If not, see <http://www.gnu.org/licenses/>.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].