| 1 | package eris; | ||
| 2 | # ABSTRACT: Eris is the Greek Goddess of Chaos | ||
| 3 | |||
| 4 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 1 | our $VERSION = '0.008'; # VERSION | |
| 8 | |||
| 9 | 1 | 1; | |
| 10 | |||
| 11 | __END__ | ||
| 12 | |||
| 13 | =pod | ||
| 14 | |||
| 15 | =encoding UTF-8 | ||
| 16 | |||
| 17 | =head1 NAME | ||
| 18 | |||
| 19 | eris - Eris is the Greek Goddess of Chaos | ||
| 20 | |||
| 21 | =head1 VERSION | ||
| 22 | |||
| 23 | version 0.008 | ||
| 24 | |||
| 25 | =head1 SYNOPSIS | ||
| 26 | |||
| 27 | eris exists to transform unstructured, chaotic log data into structured messages. | ||
| 28 | |||
| 29 | Born out of disappointment and regret of existing solutions like Logstash, | ||
| 30 | fluentd, and their kind, eris aims to make development and debugging of | ||
| 31 | parsers easy and transparent. The goal is to provide a config that be used to | ||
| 32 | to index logging data into Elasticsearch while being flexible enough to work | ||
| 33 | with log files on the system. This makes it friendly to approach from a | ||
| 34 | maintenance perspective as we don't need to run a massive app to figure out | ||
| 35 | how a log message will be restructured. | ||
| 36 | |||
| 37 | =head1 DESCRIPTION | ||
| 38 | |||
| 39 | eris is structured to be flexible, extensible, and visible in every component. | ||
| 40 | |||
| 41 | =head1 CONCEPTS | ||
| 42 | |||
| 43 | =head2 DECODER | ||
| 44 | |||
| 45 | Decoders are pluggable thanks to L<eris::role::pluggable> and they are searched | ||
| 46 | for in the the default namespace C<eris::log::decoder>. To add other | ||
| 47 | namespaces, use the C<search_path> parameter in a config file: | ||
| 48 | |||
| 49 | --- | ||
| 50 | decoders: | ||
| 51 | search_path: | ||
| 52 | - 'my::app::decoder' | ||
| 53 | |||
| 54 | Decoders operate on the raw string and provide rudimentary key/value pairs for | ||
| 55 | the other contexts to operate on. Unlike the contexts, every discovered decoder is run | ||
| 56 | for every message. | ||
| 57 | |||
| 58 | =head3 SEE ALSO | ||
| 59 | |||
| 60 | =over 4 | ||
| 61 | |||
| 62 | =item L<eris::log::decoders> | ||
| 63 | |||
| 64 | Class providing access to installed and configured decoders on the system. | ||
| 65 | |||
| 66 | =item L<eris::log::contextualizer> | ||
| 67 | |||
| 68 | Class which uses the decoders to transform the raw data into structured data. | ||
| 69 | |||
| 70 | =item L<eris::role::decoder> | ||
| 71 | |||
| 72 | The abstract role which implements a decoder. | ||
| 73 | |||
| 74 | =item L<eris::log::decoder::syslog>, L<eris::log::decoder::json> | ||
| 75 | |||
| 76 | Default implementations of decoders. | ||
| 77 | |||
| 78 | =back | ||
| 79 | |||
| 80 | =head2 CONTEXT | ||
| 81 | |||
| 82 | Contexts are pluggable and are searched for in the default namespace | ||
| 83 | C<eris::log::decoder>. To add your own namespaces, use the C<search_path> | ||
| 84 | parameter in your config file: | ||
| 85 | |||
| 86 | --- | ||
| 87 | contexts: | ||
| 88 | search_path: | ||
| 89 | - 'my::app::context' | ||
| 90 | |||
| 91 | Contexts implement the interface documented in L<eris::role::context>. There | ||
| 92 | are 4 major things to consider when implementing a new context. | ||
| 93 | |||
| 94 | =over 2 | ||
| 95 | |||
| 96 | =item B<contextualize_message> | ||
| 97 | |||
| 98 | This method is called when the context matches the event data. This is where | ||
| 99 | you can implement your own parsing or analysis of the event data. To add | ||
| 100 | context to an event, use the L<eris::log>'s C<add_context()> method. That | ||
| 101 | context data will be available to future contexts. | ||
| 102 | |||
| 103 | =item B<sample_messages> | ||
| 104 | |||
| 105 | Return an array of sample messages. This provides future developers with some | ||
| 106 | data to use in testing and enhancing your context. | ||
| 107 | |||
| 108 | =item B<field> | ||
| 109 | |||
| 110 | This specifies the field or fields that a matcher will operate on. There are | ||
| 111 | two special fields C<*> and C<_exists_>. The C<*> is used in conjunction with | ||
| 112 | a matcher of C<*> to match all messages. The C<_exists_> operator is used to | ||
| 113 | check for the existence of a key in the context. A sample use of this field | ||
| 114 | specifier is used by the L<eris::log::context::GeoIP> context with an regex | ||
| 115 | matcher to operate on any event data with field names matching C<'_ip$'>. | ||
| 116 | |||
| 117 | =item B<matcher> | ||
| 118 | |||
| 119 | Can be C<*>, a string, a regex ref, an array reference, or a code reference. | ||
| 120 | If C<matcher> and C<field> are set to C<*>, every message matches. If a | ||
| 121 | literal string, or array reference, the literal string is checked against the | ||
| 122 | value of in the C<field> specified above and returns 1 if they are equivalent. | ||
| 123 | If a regex reference, the regex is applied to the value in the specified | ||
| 124 | C<field> and the context is applied if the regex matches. A code reference | ||
| 125 | should return 1 if the event is relevant to the context and 0 if it doesn't | ||
| 126 | apply. | ||
| 127 | |||
| 128 | =back | ||
| 129 | |||
| 130 | The default C<field> is 'program', and the default matcher is a string with the | ||
| 131 | value equal to the context's C<name> attribute. For instance, | ||
| 132 | L<eris::log::context::sshd> defaults it's name to 'sshd', and since it doesn't | ||
| 133 | override the field, this context is only applied to events with a 'program' key | ||
| 134 | with a value of 'sshd'. | ||
| 135 | |||
| 136 | =head3 SEE ALSO | ||
| 137 | |||
| 138 | =over 4 | ||
| 139 | |||
| 140 | =item L<eris::log::contexts> | ||
| 141 | |||
| 142 | Class providing access to installed and configured contexts on the system. | ||
| 143 | |||
| 144 | =item L<eris::log::contextualizer> | ||
| 145 | |||
| 146 | Class which uses the contexts to transform the raw data into structured data. | ||
| 147 | |||
| 148 | =item L<eris::role::context> | ||
| 149 | |||
| 150 | The abstract role which implements a context. | ||
| 151 | |||
| 152 | =item L<eris::log::context::sshd>, L<eris::log::context::GeoIP> | ||
| 153 | |||
| 154 | Selected example contexts | ||
| 155 | |||
| 156 | =back | ||
| 157 | |||
| 158 | =head2 DICTIONARY | ||
| 159 | |||
| 160 | Dictionaries are used in conjunction with schemas to filter L<eris::log> contexts down to | ||
| 161 | only the keys and values we want. This allows better control of the data headed into storage | ||
| 162 | to prevent key space explosions. | ||
| 163 | |||
| 164 | =head3 SEE ALSO | ||
| 165 | |||
| 166 | =over 4 | ||
| 167 | |||
| 168 | =item L<eris::dictionary> | ||
| 169 | |||
| 170 | Class providing access to installed and configured dictionaries on the system. | ||
| 171 | |||
| 172 | =item L<eris::role::schema> | ||
| 173 | |||
| 174 | Class which uses the dictionaries to filter structured data into a document. | ||
| 175 | |||
| 176 | =item L<eris::role::dictionary> | ||
| 177 | |||
| 178 | The abstract role which implements a dictionary. | ||
| 179 | |||
| 180 | =item L<eris::dictionary::cee>, L<eris::dictionary::eris::debug> | ||
| 181 | |||
| 182 | Selected example contexts | ||
| 183 | |||
| 184 | =back | ||
| 185 | |||
| 186 | =head2 SCHEMA | ||
| 187 | |||
| 188 | Schemas perform the transformation from structured data into documents for | ||
| 189 | indexing. They allow control of the structure and destination of the document | ||
| 190 | being indexed. | ||
| 191 | |||
| 192 | =head3 SEE ALSO | ||
| 193 | |||
| 194 | =over 4 | ||
| 195 | |||
| 196 | =item L<eris::schemas> | ||
| 197 | |||
| 198 | Class providing access to installed and configured schemas on the system. | ||
| 199 | |||
| 200 | =item L<eris::role::schema> | ||
| 201 | |||
| 202 | The abstract role which implements a schema. | ||
| 203 | |||
| 204 | =item L<eris::schema::syslog> | ||
| 205 | |||
| 206 | Selected example contexts | ||
| 207 | |||
| 208 | =back | ||
| 209 | |||
| 210 | =head1 IMPLEMENTATIONS | ||
| 211 | |||
| 212 | The goal of eris is to provide a set of tools that can be glued together to | ||
| 213 | transform unstructured logging data into structured data and then rules for | ||
| 214 | taking that structured data and storing it somewhere. That sounds cool, but | ||
| 215 | there's nothing useful about it unless you can start playing with it now. | ||
| 216 | |||
| 217 | This is why eris ships with sample implementations. | ||
| 218 | |||
| 219 | =head2 Scripts | ||
| 220 | |||
| 221 | Here's a list of the scripts installed along with eris so you can start | ||
| 222 | breaking things. | ||
| 223 | |||
| 224 | =over 4 | ||
| 225 | |||
| 226 | =item B<eris-context.pl> | ||
| 227 | |||
| 228 | This script allows you to do a few useful things. To see what happens to unstructured data, | ||
| 229 | you can try performing some simple transforms via the built-in C<sample_messages>: | ||
| 230 | |||
| 231 | eris-context.pl --sample sshd | ||
| 232 | |||
| 233 | If you'd like to see what those samples look like as ElasticSearch build requests, you can: | ||
| 234 | |||
| 235 | eris-context.pl --sample sshd --bulk | ||
| 236 | |||
| 237 | Without the C<--sample> argument, you can feed data to it using STDIN or a file as it'll use | ||
| 238 | the Perl magic diamond to read data until an EOF is reached. | ||
| 239 | |||
| 240 | To see what the bulk output would look like from a few sources: | ||
| 241 | |||
| 242 | Via pipe: | ||
| 243 | |||
| 244 | tail /var/log/messages | eris-context.pl -b | ||
| 245 | |||
| 246 | Via a file: | ||
| 247 | |||
| 248 | eris-context.pl -b /var/log/messsages | ||
| 249 | |||
| 250 | Via STDIN for testing or manually importing data: | ||
| 251 | |||
| 252 | eris-context.pl -b | ||
| 253 | |||
| 254 | The script provides more options, pull up it's help with: | ||
| 255 | |||
| 256 | eris-context.pl --help | ||
| 257 | |||
| 258 | =item B<eris-field-lookup.pl> | ||
| 259 | |||
| 260 | This script allows you to query the L<eris::dictionary> to see what it knows | ||
| 261 | about a particular field. | ||
| 262 | |||
| 263 | eris-field-lookup.pl src_ip | ||
| 264 | |||
| 265 | =item B<eris-es-indexer.pl> | ||
| 266 | |||
| 267 | This is a sample implementation that performs indexing of data received over | ||
| 268 | syslog to an ElasticSearch cluster. It will parse all messages passed to it | ||
| 269 | over STDIN and send them to an ElasticSearch cluster. It's single threaded, so | ||
| 270 | it won't be able to keep up with a full speed log load. See it's help output | ||
| 271 | for options and details: | ||
| 272 | |||
| 273 | eris-es-indexer.pl --help | ||
| 274 | |||
| 275 | =item B<eris-stdin-listener.pl> | ||
| 276 | |||
| 277 | This is a wrapper around C<eris-es-indexer.pl> using L<POE::Component::WheelRun::Pool> | ||
| 278 | to provide a pool of workers for processing log data at scale. To use it with syslog-ng: | ||
| 279 | |||
| 280 | destination d_eris { program("/usr/local/bin/eris-stdin-listener.pl" keep-alive(); ); }; | ||
| 281 | log { source(src_network); destination(d_eris); }; | ||
| 282 | |||
| 283 | See it's help output for options: | ||
| 284 | |||
| 285 | eris-stdin-listener.pl --help | ||
| 286 | |||
| 287 | =item B<eris-eris-client.pl> | ||
| 288 | |||
| 289 | This is a wrapper around C<eris-es-indexer.pl> for use in environments using | ||
| 290 | the L<POE::Component::Server::eris> syslog service. This service is a simple, | ||
| 291 | stateless syslog message dispatch system used primarily for development of new | ||
| 292 | syslog parser use cases. It transforms the syslog stream into a subscription | ||
| 293 | service any user on the local system can tap. IF you're using that server, you | ||
| 294 | can run the C<eris-eris-client.pl> to leverage L<POE::Component::Client::eris> | ||
| 295 | to receive messages from the upstream and dispatch them to a worker pool of | ||
| 296 | C<eris-es-indexer.pl>'s. For more information, see: | ||
| 297 | |||
| 298 | eris-eris-client.pl --help | ||
| 299 | |||
| 300 | =back | ||
| 301 | |||
| 302 | =head1 AUTHOR | ||
| 303 | |||
| 304 | Brad Lhotsky <brad@divisionbyzero.net> | ||
| 305 | |||
| 306 | =head1 COPYRIGHT AND LICENSE | ||
| 307 | |||
| 308 | This software is Copyright (c) 2015 by Brad Lhotsky. | ||
| 309 | |||
| 310 | This is free software, licensed under: | ||
| 311 | |||
| 312 | The (three-clause) BSD License | ||
| 313 | |||
| 314 | =cut | ||