Debian Codegraph @

doc/schemas/logstash/radius-mapping.sh

raw
1 #! /bin/sh
2
3 # Create an elasticsearch template mapping for RADIUS data
4 # Matthew Newton
5 # April 2019
6
7 # This should be run on an elasticsearch node. Alternatively,
8 # adjust the curl URI below.
9
10 # This version has been tested on elasticsearch 6.7.0
11
12 # The template will be called "radius", and will apply to all
13 # indices prefixed with "radius-".
14 #
15 # As not all RADIUS attributes are known to begin with it has the
16 # following starting point that can be modified to suit the local
17 # configuration:
18 #
19 # Acct-Input- or Acct-Output- attributes are numbers;
20 # Acct-Session-Time is a number;
21 # Everything else is a keyword, which is a non-analysed string.
22
23 # Additionally, the supplied logstash config will try and extract
24 # MAC addresses, IP addresses and ports from the data. These are
25 # stored with suffixes on the respective attribute. For example,
26 # an attribute
27 #
28 # Called-Station-Id := "10.0.4.6[4500]"
29 #
30 # will be broken down into the following fields in elasticsearch:
31 #
32 # Called-Station-Id = "10.0.4.6[4500]"
33 # Called-Station-Id_ip = "10.0.4.6"
34 # Called-Station-Id_port = "4500"
35 #
36 # This mapping ensures that these have an appropriate data type.
37
38
39 curl -s -XPUT -H 'Content-Type: application/json' '127.0.0.1:9200/_template/radius' -d '
40 {
41 "template":"radius-*",
42 "order":0,
43 "mappings":{
44 "doc":{
45
46 "properties": {
47 "@timestamp": { "format" : "date_optional_time", "type" : "date" },
48 "@version": { "type" : "keyword" },
49 "message": { "type" : "text" },
50 "Acct-Session-Time": { "type" : "long" },
51 "offset": { "type" : "long" }
52 },
53
54 "dynamic_templates": [
55
56 { "acct_io_numbers": {
57 "match_pattern": "regex",
58 "match": "^Acct-(Input|Output)-.*$",
59 "mapping": {
60 "type": "long"
61 }
62 }
63 },
64
65 { "ipv4_address": {
66 "path_match": "*_ip",
67 "mapping": {
68 "type": "ip"
69 }
70 }
71 },
72
73 { "network_port": {
74 "path_match": "*_port",
75 "mapping": {
76 "type": "integer"
77 }
78 }
79 },
80
81 { "long_number": {
82 "path_match": "*_long",
83 "mapping": {
84 "type": "long"
85 }
86 }
87 },
88
89 { "no_analyze_strings": {
90 "match": "*",
91 "mapping": {
92 "type": "keyword"
93 }
94 }
95 }
96
97 ]
98 }
99 }
100 }'