Skip to content

HOWTO Handle several technos in one topology

Why do that

In a particular context, when you have to handle several technologies in one channel. For example, when all your data flow enter on the same port number.

One punch Bolt to divise them all

In that case, the bad thing to do is to have one parser for all the technologies. The logs are different, with their own significance and so, their own normalization. Furthermore, the processing cost is bigger because each log will be process by one big parser.

So the good practice is to have one parser by technology and an other parser upstream in charge of dispatching the logs.

That's why we provide a efficient way to dispatch. The first punch_bolt will slighlty parse the log in order to identify the techology and save it in an new field, for example in [logs][_log_type] The second punch_bolt will process the logs depending on the technology present in the [logs][_log_type] field.

Here an explanation diagram :

image

Example

Available in the standalone punch package :

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
{
  "tenant": "mytenant",
  "channel": "universal",
  "name": "single",
  "meta": {
    "tenant": "mytenant",
    "channel": "universal"
  },
  "spouts": [
    {
      "type": "syslog_spout",
      "spout_settings": {
        "listen": {
          "proto": "tcp",
          "host": "0.0.0.0",
          "port": 10000
        }
      },
      "storm_settings": {
        "executors": 1,
        "component": "syslog_spout_tcp",
        "publish": [
          {
            "stream": "logs",
            "fields": [
              "log",
              "_ppf_local_host",
              "_ppf_local_port",
              "_ppf_remote_host",
              "_ppf_remote_port",
              "_ppf_id",
              "_ppf_timestamp"
            ]
          }
        ]
      }
    }
  ],
  "bolts": [
    {
      "type": "punch_bolt",
      "bolt_settings": {
        "punchlet": [ "./autodiscovery.punch" ]
      },
      "storm_settings": {
        "component": "autodiscovery_bolt",
        "subscribe": [
          {
            "component": "syslog_spout_tcp",
            "stream": "logs"
          }
        ],
        "publish": [
          {
            "stream": "logs",
            "fields": [ 
              "log", 
              "_log_type", 
              "_ppf_local_host",
              "_ppf_local_port",
              "_ppf_remote_host",
              "_ppf_remote_port",
              "_ppf_id",
              "_ppf_timestamp"
            ]
          }
        ]
      }
    },
    {
      "type": "punch_bolt_dispatcher",
      "bolt_settings": {
        "dispatcher_field" : "_log_type",
        "dispatcher_map" : {
          "sourcefire" : {
            "punchlet" : [
              "./input.punch",
              "./parsing_syslog_header.punch",
              "standard/sourcefire/parsing.punch",
              "standard/common/geoip.punch"
            ]
          },
          "apache_httpd" : {
            "punchlet_json_resources" : [
              "standard/apache_httpd/http_codes.json"
              ,"standard/apache_httpd/taxonomy.json"
            ],
            "punchlet" : [
              "./input.punch",
              "./parsing_syslog_header.punch",
              "standard/apache_httpd/parsing.punch",
              "standard/apache_httpd/enrichment.punch",
              "standard/apache_httpd/normalization.punch",
              "standard/common/geoip.punch"
            ]
          },
          "stormshield_networksecurity" : {
            "punchlet": [
              "./input.punch",
              "./parsing_syslog_header.punch",
              "standard/stormshield_networksecurity/parsing.punch",
              "standard/common/geoip.punch"
            ]
          },
          "websense_web_security" : {
            "punchlet_json_resources": [
              "standard/websense_web_security/enrichment_category.json",
              "standard/websense_web_security/enrichment_disposition.json"
            ],
            "punchlet": [
              "./input.punch",
              "./parsing_syslog_header.punch",
              "standard/websense_web_security/parsing.punch",
              "standard/websense_web_security/enrichment.punch",
              "standard/common/geoip.punch"
            ]
          }
        }
      },

      "storm_settings": {
        "executors": 1,
        "component": "parser_bolt",
        "publish": [
          {
            "stream": "logs",
            "fields": [
              "raw_log",
              "log",
              "_ppf_id",
              "_ppf_timestamp",
              "es_index"
            ]
          },
          {
            "stream": "_ppf_errors",
            "fields": [
              "_ppf_error_message",
              "_ppf_error_document",
              "_ppf_id"
            ]
          }
        ],
        "subscribe": [
          {
            "component": "autodiscovery_bolt",
            "stream": "logs",
            "grouping": "localOrShuffle"
          }
        ]
      }
    },
    {
      "type": "elasticsearch_bolt",
      "bolt_settings": {
        "cluster_id": "es_search",
        "per_stream_settings": [
          {
            "stream": "logs",
            "index": {
              "type": "daily",
              "prefix": "mytenant-events-"
            },
            "document_json_field": "log",
            "document_id_field": "_ppf_id",
            "additional_document_value_fields": [
              {
                "type": "date",
                "document_field": "@timestamp",
                "format": "iso"
              }
            ]
          },
          {
            "stream": "_ppf_errors",
            "document_value_fields": [
              "_ppf_error_message",
              "_ppf_error_document",
              "_ppf_id"
            ],
            "index": {
              "type": "daily",
              "prefix": "mytenant-events-"
            },
            "document_id_field": "_ppf_id",
            "additional_document_value_fields": [
              {
                "type": "date",
                "document_field": "@timestamp",
                "format": "iso"
              }
            ]
          }
        ]
      },
      "storm_settings": {
        "executors": 1,
        "component": "elasticsearch_bolt",
        "subscribe": [
          {
            "component": "parser_bolt",
            "stream": "logs"
          },
          {
            "component": "parser_bolt",
            "stream": "_ppf_errors"
          }
        ]
      }
    }
  ],
  "metrics": {
    "reporters": [
      {
        "type": "elasticsearch",
        "cluster_name": "es_search"
      }
    ]
  },
  "storm_settings": {
    "metrics_consumers": [
      "org.apache.storm.metric.LoggingMetricsConsumer"
    ],
    "topology.builtin.metrics.bucket.size.secs": 30,
    "supervisor.monitor.frequency.secs": 60,
    "topology.max.spout.pending": 10000,
    "topology.enable.message.timeouts": true,
    "topology.message.timeout.secs": 30,
    "topology.worker.childopts": "-server -Xms128m -Xmx128m",
    "topology.receiver.buffer.size": 32,
    "topology.executor.receive.buffer.size": 16384,
    "topology.executor.send.buffer.size": 16384,
    "topology.transfer.buffer.size": 32,
    "topology.worker.shared.thread.pool.size": 4,
    "topology.disruptor.wait.strategy": "com.lmax.disruptor.BlockingWaitStrategy",
    "topology.spout.wait.strategy": "org.apache.storm.spout.SleepSpoutWaitStrategy",
    "topology.sleep.spout.wait.strategy.time.ms": 50,
    "topology.workers": 1
  }
}