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