• Stars
    star
    108
  • Rank 321,259 (Top 7 %)
  • Language
    Ruby
  • Created over 10 years ago
  • Updated almost 10 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A collection of command line utilities for working with logfmt.

hutils

A small collection of utilies for logfmt processing.

Installation

gem install hutils

Requires Ruby 2.1.0 or later.

Utilities

lcut

lcut extracts values from a logfmt trace based on some field name.

$ ltap 'instrumentation app=api earliest=-1m at=finish' | lcut method path
GET     /providers/users/search
GET     /vendor/resources/6307854
GET     /health
GET     /vendor/resources/6007506
GET     /vendor/resources/7117492

lfmt

lfmt prettifies logfmt lines as they emerge from a stream, and highlights their key sections.

(Note that the example below doesn't demonstrate color, which is one of the more important features of logfmt.)

$ ltap 'instrumentation app=api earliest=-1m at=finish' | lfmt
[email protected] app: api at: finish component: manager_apiauthorized elapsed: 0.008 instance_name: api.108081 instrumentation length: 339 method: GET path: /providers/users/search request_id: ef82825d-4c10-41f3-89ed-6bf805aa4513 status: 200 user: [email protected] user_id: 105750 version: 1
[email protected] app: api at: finish elapsed: 0.001 instance_name: api.136540 instrumentation method: GET path: /vendor/resources/6307854 request_id: 055df716-fc62-4554-b976-e2fe2472e107 status: 200 user: [email protected] user_id: 97546 version: 2
[email protected] app: api at: finish elapsed: 0.000 instance_name: api.93579 instrumentation method: GET path: /health request_id: 6af07088-82af-4f50-87c1-8b5d248807f0 status: 200 user: [email protected] user_id: 105750 version: 1
[email protected] app: api at: finish elapsed: 0.174 instance_name: api.108081 instrumentation method: GET path: /vendor/resources/6007506 request_id: ef82825d-4c10-41f3-89ed-6bf805aa4513 status: 200 user: [email protected] user_id: 105750 version: 1
[email protected] app: api at: finish elapsed: 0.162 instance_name: api.108081 instrumentation method: GET path: /vendor/resources/7117492 request_id: 7480424d-5a8a-488a-a32a-55812fde5f4b status: 200 user: [email protected] user_id: 105750 version: 1

ltap

ltap accesses messages from popular log providers in a consistent way so that it can easily be parsed by other utilities that operate on logfmt traces. Currently supported providers are Papertrail and Splunk.

$ ltap 'instrumentation app=api earliest=-1m at=finish'
[email protected] instrumentation method=GET path=/providers/users/search request_id=d5c373fd-d1ec-4986-bc43-2617431116f2 at=finish elapsed=0.008 length=339 status=200 app=api instance_name=api.108081 version=1 component=manager_apiauthorized app=api instance_name=api.108081 request_id=ef82825d-4c10-41f3-89ed-6bf805aa4513 version=1 [email protected] user_id=105750
[email protected] instrumentation method=GET path=/vendor/resources/6307854 request_id=d2f25032-9aaa-41e9-8aaf-9a46a44523d1 at=finish elapsed=0.110 status=200 app=api instance_name=api.136540 version=1 [email protected] user_id=105750step=check_oauth_scope! request_id=055df716-fc62-4554-b976-e2fe2472e107 version=2 [email protected] user_id=97546 app=api instance_name=api.136540 at=finish elapsed=0.001
[email protected] instrumentation method=GET path=/health request_id=6af07088-82af-4f50-87c1-8b5d248807f0 at=finish elapsed=0.000 status=200 app=api instance_name=api.93579 version=1 [email protected] user_id=105750
[email protected] instrumentation method=GET path=/vendor/resources/6007506 request_id=ef82825d-4c10-41f3-89ed-6bf805aa4513 at=finish elapsed=0.174 status=200 app=api instance_name=api.108081 version=1 [email protected] user_id=105750
[email protected] instrumentation method=GET path=/vendor/resources/7117492 request_id=7480424d-5a8a-488a-a32a-55812fde5f4b at=finish elapsed=0.162 status=200 app=api instance_name=api.108081 version=1 [email protected] user_id=105750

ltap can be configured using ~/.ltap. A sample Papertrail configuration looks like the following:

[global]
profile = my_papertrail

[my_papertrail]
key = an-api-key
type = papertrail

A sample Splunk configuration:

[global]
profile = my_splunk

[my_splunk]
earliest = -24h
type = splunk
url = https://brandur:[email protected]:8089

lviz

lviz helps to visualize logfmt output by building a tree out of some set of data by combining common sets of key/value pairs into shared parent nodes. Messages remain ordered by time, which removes some potential for commonality, but in many cases a disproportionate number of attributes can be moved up to nodes close to the top of the tree. Output is colorized and important keys are highlighted to make traces more easily digestible.

$ ltap 'instrumentation app=api earliest=-1m at=finish' | lviz
+ app: api
  instrumentation
  method: GET
  status: 200

        + [email protected]
          component: manager_apiauthorized
          elapsed: 0.008
          instance_name: api.108081
          length: 339
          path: /providers/users/search
          request_id: ef82825d-4c10-41f3-89ed-6bf805aa4513
          user: [email protected]
          user_id: 105750
          version: 1

        + [email protected]
          elapsed: 0.001
          instance_name: api.136540
          path: /vendor/resources/6307854
          request_id: 055df716-fc62-4554-b976-e2fe2472e107
          user: [email protected]
          user_id: 97546
          version: 2

        + user: [email protected]
          user_id: 105750
          version: 1

                + [email protected]
                  elapsed: 0.000
                  instance_name: api.93579
                  path: /health
                  request_id: 6af07088-82af-4f50-87c1-8b5d248807f0

                + [email protected]
                  instance_name: api.108081

                        + elapsed: 0.174
                          path: /vendor/resources/6007506
                          request_id: ef82825d-4c10-41f3-89ed-6bf805aa4513

                        + elapsed: 0.162
                          path: /vendor/resources/7117492
                          request_id: 7480424d-5a8a-488a-a32a-55812fde5f4b

lviz can be configured with ~/.lviz. For example:

[global]
highlights = path,user
ignore = at

lviz can also produce a compact mode of output using -c or --compact.

Testing

bundle install
bundle exec rake

More Repositories

1

redis-cell

A Redis module that provides rate limiting in Redis as a single command.
Rust
1,189
star
2

sorg

A Go-based static site generator that compiles brandur.org.
Go
486
star
3

json_schema

A JSON Schema V4 and Hyperschema V4 parser and validator.
Ruby
230
star
4

heroku-http-api-design

The Heroku HTTP API Design Guide, forked to look more like its original pre-GitBook state with a more easily digestible single-page format.
167
star
5

tmux-extra

Configuration and scripts for sane Tmux default behavior.
Shell
108
star
6

rocket-rides-atomic

Ruby
94
star
7

sinatra-router

A tiny vendorable router that makes it easy to try routes from a number of different modular Sinatra applications.
Ruby
61
star
8

rhttpserve

A tiny HTTP server that can serve files out of any rclone remote.
Go
39
star
9

rocket-rides-unified

Ruby
27
star
10

podcore

Rust
22
star
11

microservices

21
star
12

blackswan

A project designed to provide personal data ownership and display.
JavaScript
21
star
13

heroku-buildpack-mono

ASP.NET buildpack deployed on top of Mono and XSP.
Shell
18
star
14

postgres-practices

18
star
15

rocket-rides-scalable

Ruby
16
star
16

singularity

A demonstration of a very simple static site generator that deploys to S3 through Travis CI.
Go
15
star
17

dorian

A personal identity manager and aggregator written in Rails 3.1.
JavaScript
13
star
18

casseo

A Graphite dashboard for the command line.
Ruby
12
star
19

modulir

Modulir is an experimental mini-framework for static site generation.
Go
11
star
20

connections-test

Go
10
star
21

wanikaniapi

A Go client for WaniKani's API (https://docs.api.wanikani.com/).
Go
10
star
22

qself

Qself is a small tool to sync personal data from APIs down to local TOML files for easier portability and storage.
Go
10
star
23

cmark2jira

Translate good CommonMark into bad JIRA markup.
Rust
9
star
24

brandur

Go
9
star
25

hncheck

A very simple app that checks to see if something under one of your domains has been submitted to HN, and emails you if it has.
Go
9
star
26

simple-schema

9
star
27

que-degradation-test

Ruby
8
star
28

org

A now defunct project that served my personal site.
8
star
29

mutelight-v2

Content for my technical journal at mutelight.org, designed to be used with Hekla.
Ruby
8
star
30

geotools

Updated mirror for the Geotools.Net project.
C#
8
star
31

redis-haskell

Haskell bindings for Redis, a fast persistent key-value store.
Haskell
7
star
32

logfmt

logfmt parser in Rust.
Rust
7
star
33

hekla

Responsive blogging engine for ephemeral platforms.
JavaScript
7
star
34

mastodon-cross-post

A simple project that cross-posts tweets to Mastodon.
Go
6
star
35

passages-signup

A backend for the signup forms of my newsletters "Nanoglyph" and "Passages & Glass".
Go
6
star
36

heroku-agent

A lightweight process that can communicate with the Heroku CLI and hk to provide more expendient fulfillment of API requests and better convenience of use.
Go
6
star
37

simplebox

Package simplebox provides a simple, easy-to-use cryptographic API where all of the hard decisions have been made for you in advance.
Go
6
star
38

neospring

Go
6
star
39

logs

Ruby
5
star
40

perpetual

Go
5
star
41

slides

An extremely simplistic logs-as-data implementation.
Ruby
5
star
42

rack-instruments

Rack middleware providing basic instrumentation.
Ruby
4
star
43

http_accept

Simple library for HTTP Accept header parsing and ordering.
Ruby
4
star
44

composable

Slides for my talk "Post-Rails? Composable Apps with a First-class API".
JavaScript
4
star
45

middleware-rust

Rust
4
star
46

heroku-mono-build

Heroku-based build recipe for Mono and XSP.
Shell
4
star
47

rack-robots

Rack middleware that denies all robots for staging and development environments.
Ruby
4
star
48

obsidian

Web framework in Haskell to power factz.org. Deprecated in favor of the Rails Facts app.
Haskell
3
star
49

the-surf

Article content for the Surf.
Shell
3
star
50

facts-cli

Command line interface based on Thor for the Facts sever project.
Ruby
3
star
51

mutelight-v1

Nanoc source for my blog at mutelight.org. Deprecated in favor of Askja.
Ruby
3
star
52

artifice-excon

A version of Wycat's Artifice for use with Excon.
Ruby
3
star
53

facts-api

Facts API.
Ruby
3
star
54

heroku-buildpack-mono-build

Builds binaries for the herok-buildpack-mono project.
Shell
2
star
55

db-fill

PLpgSQL
2
star
56

heroku-api-blog

JavaScript
2
star
57

nanowrimo10

My current contribution for National Novel Writing Month. See http://nanowrimo.org.
2
star
58

rakenet

Command line build and testing infrastructure for a .NET project.
Ruby
2
star
59

dping

Ruby
2
star
60

cping

Go
2
star
61

mozjpeg-builder

2
star
62

zendtools.vim

Various useful functions for working in PHP with Zend.
Vim Script
2
star
63

surf

Source code for my blog 'the Surf', uses a custom (and included) static generator.
Ruby
2
star
64

sharks

A scraping and data visualization service for Global Shark Attack File records.
Ruby
2
star
65

spring83-keygen

2
star
66

gal

Go
2
star
67

brandur-old

Rails app to power brandur.org. This has been deprecated in favor of Dorian.
Ruby
2
star
68

service-stub-example

Ruby
2
star
69

imagemagick-builder

2
star
70

sequel-instruments

Basic instrumentation for Sequel.
Ruby
2
star
71

facts-nodejs

Facts database for increasing retention of general knowledge, and for winning arguments. Deprecated in favor of the Rails version.
JavaScript
2
star
72

facts

A tool for getting smarter and winning arguments.
Ruby
2
star
73

d2

A cross-version compatible shortcut for invoking a Ruby debugger.
Ruby
2
star
74

omniauth-heroku

Ruby
2
star
75

postgres-table-rename-test

Ruby
2
star
76

askja

Minimalist blogging platform written in Rails as a flexible alternative to static generators.
Ruby
2
star
77

facts-web

Frontend interface that talks to facts-api.
JavaScript
2
star
78

asp-net-sample

Sample ASP.NET MVC application that can run on Heroku.
C#
1
star
79

wgt2

Go
1
star
80

magmv

A program to rename poorly titled magazine PDF files.
Go
1
star
81

deathguild

Creates Spotify playlists for each night of Death Guild.
HTML
1
star
82

cheat-sheets-dev

A set of cheat sheets designed to centralize information to quicken the development process.
1
star
83

heroku-hyper-schema

1
star
84

umbrella-rust

Rust
1
star
85

certrotate

Go
1
star
86

php-mbstring-overload-tests

Simple test suite to demonstrate PHP's mbstring function overloading.
C
1
star
87

the-surf-old

Next generation of the Surf (journal). Deprecated in favor Hekla.
Ruby
1
star
88

schemadoc

Ruby
1
star
89

fireball

Go
1
star
90

qself-brandur

1
star
91

submodule-dud

1
star
92

archlinux-packages

My contributed PKGBUILDs for the Archlinux AUR.
1
star
93

millstone

1
star
94

neospring-bridge

Go
1
star
95

csrf

Go
1
star
96

wkunburn

Go
1
star
97

dummy

Empty repository.
1
star
98

wgt

A WGT-related playground.
Go
1
star
99

transaction-philosophy

HTML
1
star
100

tailwind-experimenting

CSS
1
star