update link to upper-constraints.txt
[dcaegen2.git] / docs / sections / services / snmptrap / logging.rst
1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2 .. http://creativecommons.org/licenses/by/4.0
3
4 Logging
5 =======
6
7 Logging is controlled by the configuration provided to **trapd** by CBS,
8 or via the fallback config file specified as the environment
9 variable "CBS_SIM_JSON" at startup.  The section of the JSON configuration
10 that influences the various forms of application logging is referenced
11 throughout this document, with examples.
12
13 Using the JSON configuration, a base directory is specified for application
14 data and EELF log files.  Specific filenames (again, from the JSON
15 config) are appended to the base directory value to create a full-path
16 filename for use by SNMPTRAP.
17
18 Also available is the ability to modify how frequently logs are rolled to
19 time-stamped versions (and a new empty file is started) as well as what
20 severity level to log to program diagnostic logs.  The actual archival (to a
21 timestamped filename) occurs when the first trap is
22 received **in a new hour** (or minute, or day - depending
23 on "roll_frequency" value).
24
25 Defaults are shown below:
26
27 .. code-block:: json
28
29     {"files": {
30         "<other json data>": "...",
31         "roll_frequency": "day",
32         "minimum_severity_to_log": 3,
33         "<other json data>": "..."
34     }}
35
36
37 Roll Frequency
38 """"""""""""""
39
40 Roll frequency can be modified based on your environment (e.g. if trapd is handling a
41 heavy trap load, you will probably want files to roll more frequently).  Valid "roll_frequency" values are:
42
43 - minute
44 - hour
45 - day
46
47 Minimum Severity To Log
48 """""""""""""""""""""""
49
50 Logging levels should be modified based on your need.  Log levels in lab environments should be "lower"
51 (e.g. minimum severity to log = "0" creates verbose logging) vs. production (values of "3" and above is a good choice).
52
53 Valid "minimum_severity_to_log" values are:
54
55 - "1"   (debug mode - everything you want to know about process, and more.  *NOTE:* Not recommended for production environments)
56 - "2"   (info - verbose logging.  *NOTE:* Not recommended for production environments)
57 - "3"   (warnings - functionality not impacted, but abnormal/uncommon event)
58 - "4"   (critical - functionality impacted, but remains running)
59 - "5"   (fatal - causing runtime exit)
60
61
62 WHERE ARE THE LOG FILES?
63 ------------------------
64
65 APPLICATION DATA
66 ^^^^^^^^^^^^^^^^
67
68 **trapd** produces application-specific logs (e.g. trap logs/payloads,
69 etc) as well as various other statistical and diagnostic logs.  The
70 location of these logs is controlled by the JSON config, using these
71 values:
72
73 .. code-block:: json
74
75     {"files": {
76         "runtime_base_dir": "/opt/app/snmptrap",
77         "log_dir": "logs",
78         "data_dir": "data",
79         "pid_dir": "tmp",
80         "arriving_traps_log": "snmptrapd_arriving_traps.log",
81         "snmptrapd_diag": "snmptrapd_prog_diag.log",
82         "traps_stats_log": "snmptrapd_stats.csv",
83         "perm_status_file": "snmptrapd_status.log",
84         "roll_frequency": "hour",
85         "minimum_severity_to_log": 2,
86         "<other json data>": "..."
87     }}
88
89 The base directory for all data logs is specified with:
90
91     **runtime_base_dir**
92
93 Remaining log file references are appended to the *runtime_base_dir*
94 value to specify a logfile location.  The result using the
95 above example would create the files:
96
97 .. code-block:: bash
98
99     /opt/app/snmptrap/logs/snmptrapd_arriving_traps.log
100     /opt/app/snmptrap/logs/snmptrapd_prog_diag.log
101     /opt/app/snmptrap/logs/snmptrapd_stats.csv
102     /opt/app/snmptrap/logs/snmptrapd_status.log
103
104
105 ARRIVING TRAPS
106 ^^^^^^^^^^^^^^^
107
108 **trapd** logs all arriving traps.  These traps are saved in a
109 filename created by appending *runtime_base_dir*, *log_dir*
110 and *arriving_traps_log* from the JSON config.  Using the example
111 above, the resulting arriving trap log would be:
112
113 .. code-block:: bash
114
115     /opt/app/snmptrap/logs/snmptrapd_arriving_traps.log
116
117 An example from this log is shown below:
118
119 .. code-block:: none
120
121     1529960544.4896748 Mon Jun 25 17:02:24 2018; Mon Jun 25 17:02:24 2018 com.att.dcae.dmaap.IST3.DCAE-COLLECTOR-UCSNMP 15299605440000 1.3.6.1.4.1.999.0.1 server001 127.0.0.1 server001 v2c 751564798 0f40196a-78bb-11e8-bac7-005056865aac , "varbinds": [{"varbind_oid": "1.3.6.1.4.1.999.0.1.1", "varbind_type": "OctetString", "varbind_value": "TEST TRAP"}]
122
123 *NOTE:*  Format of this log will change with 1.5.0; specifically, "varbinds" section will be reformatted/json struct removed and will be replaced with a flat file format.
124
125 PUBLISHED TRAPS
126 ^^^^^^^^^^^^^^^
127
128 SNMPTRAP's main purpose is to receive and decode SNMP traps, then
129 publish the results to a configured DMAAP/MR message bus.  Traps that
130 are successfully published (e.g. publish attempt gets a "200/ok"
131 response from the DMAAP/MR server) are logged to a file named by
132 the technology being used combined with the topic being published to.
133
134 If you find a trap in this published log, it has been acknowledged as
135 received by DMAAP/MR.  If consumers complain of "missing traps", the
136 source of the problem will be downstream (*not with SNMPTRAP*) if
137 the trap has been logged here.
138
139 For example, with a json config of:
140
141 .. code-block:: json
142
143     "dmaap_info": {
144         "location": "mtl5",
145         "client_id": null,
146         "client_role": null,
147         "topic_url": "http://172.17.0.1:3904/events/ONAP-COLLECTOR-SNMPTRAP"
148
149 and
150
151 .. code-block:: json
152
153     "files": {
154         "**runtime_base_dir**": "/opt/app/snmptrap",
155
156 result in traps that are confirmed as published (200/ok response from DMAAP/MR) logged to the file:
157
158 .. code-block:: bash
159
160     /opt/app/snmptrap/logs/DMAAP_ONAP-COLLECTOR-SNMPTRAP.json
161
162 An example from this JSON log is shown below:
163
164 .. code-block:: json
165
166     {
167         "uuid": "0f40196a-78bb-11e8-bac7-005056865aac",
168         "agent address": "127.0.0.1",
169         "agent name": "server001",
170         "cambria.partition": "server001",
171         "community": "",
172         "community len": 0,
173         "epoch_serno": 15299605440000,
174         "protocol version": "v2c",
175         "time received": 1529960544.4896748,
176         "trap category": "DCAE-COLLECTOR-UCSNMP",
177         "sysUptime": "751564798",
178         "notify OID": "1.3.6.1.4.1.999.0.1",
179         "notify OID len": 9,
180         "varbinds": [
181             {
182                 "varbind_oid": "1.3.6.1.4.1.999.0.1.1",
183                 "varbind_type": "OctetString",
184                 "varbind_value": "TEST TRAP"
185             }
186         ]
187     }
188
189
190
191 EELF
192 ^^^^
193
194 For program/operational logging, **trapd** follows the EELF logging
195 convention.  Please be aware that the EELF specification results in
196 messages spread across various files.  Some work may be required to
197 find the right location (file) that contains the message you are
198 looking for.
199
200 EELF logging is controlled by the configuration provided
201 to **trapd** by CBS, or via the fallback config file specified
202 as an environment variable "CBS_SIM_JSON" at startup.  The section
203 of that JSON configuration that influences EELF logging is:
204
205 .. code-block:: json
206
207     {"files": {
208         "<other json data>": "...",
209         "**eelf_base_dir**": "/opt/app/snmptrap/logs",
210         "eelf_error": "error.log",
211         "eelf_debug": "debug.log",
212         "eelf_audit": "audit.log",
213         "eelf_metrics": "metrics.log",
214         "roll_frequency": "hour"
215     },
216     "<other json data>": "..."
217     }
218
219
220 The base directory for all EELF logs is specified with:
221
222         **eelf_base_dir**
223
224 Remaining eelf_<file> references are appended to the eelf_base_dir value
225 to specify a logfile location.  The result using the above example would
226 create the files:
227
228 .. code-block:: bash
229
230         /opt/app/snmptrap/logs/error.log
231         /opt/app/snmptrap/logs/debug.log
232         /opt/app/snmptrap/logs/audit.log
233         /opt/app/snmptrap/logs/metrics.log
234
235 Again using the above example configuration, these files will be rolled
236 to an archived/timestamped version hourly.  The actually archival (to a
237 timestamped filename) occurs when the first trap is
238 received **in a new hour** (or minute, or day - depending
239 on "roll_frequency" value).
240
241 Error / Warning Messages
242 ------------------------
243
244 Program Diagnostics
245 ^^^^^^^^^^^^^^^^^^^
246
247 Detailed application log messages can be found in "snmptrapd_diag" (JSON
248 config reference).  These can be very verbose and roll quickly
249 depending on trap arrival rates, number of varbinds encountered,
250 minimum_severity_to_log setting in JSON config, etc.
251
252 In the default config, this file can be found at:
253
254 .. code-block:: bash
255
256     /opt/app/snmptrap/logs/snmptrapd_diag.log
257
258 Messages will be in the general format of:
259
260 .. code-block:: none
261
262     2018-04-25T17:28:10,305|<module>|snmptrapd||||INFO|100||arriving traps logged to: /opt/app/snmptrap/logs/snmptrapd_arriving_traps.log
263     2018-04-25T17:28:10,305|<module>|snmptrapd||||INFO|100||published traps logged to: /opt/app/snmptrap/logs/DMAAP_com.att.dcae.dmaap.IST3.DCAE-COLLECTOR-UCSNMP.json
264     2018-04-25T17:28:10,306|<module>|snmptrapd||||INFO|100||Runtime PID file: /opt/app/snmptrap/tmp/snmptrapd.py.pid
265     2018-04-25T17:28:48,019|snmp_engine_observer_cb|snmptrapd||||DETAILED|100||snmp trap arrived from 192.168.1.139, assigned uuid: 1cd77e98-48ae-11e8-98e5-005056865aac
266     2018-04-25T17:28:48,023|snmp_engine_observer_cb|snmptrapd||||DETAILED|100||dns cache expired or missing for 192.168.1.139 - refreshing
267     2018-04-25T17:28:48,027|snmp_engine_observer_cb|snmptrapd||||DETAILED|100||cache for server001 (192.168.1.139) updated - set to expire at 1524677388
268     2018-04-25T17:28:48,034|snmp_engine_observer_cb|snmptrapd||||DETAILED|100||snmp trap arrived from 192.168.1.139, assigned uuid: 0f40196a-78bb-11e8-bac7-005056
269     2018-04-25T17:28:48,036|notif_receiver_cb|snmptrapd||||DETAILED|100||processing varbinds for 0f40196a-78bb-11e8-bac7-005056
270     2018-04-25T17:28:48,040|notif_receiver_cb|snmptrapd||||DETAILED|100||adding 0f40196a-78bb-11e8-bac7-005056 to buffer
271
272     2018-06-25T21:02:24,491|notif_receiver_cb|snmptrapd||||DETAILED|100||trap 0f40196a-78bb-11e8-bac7-005056865aac : {"uuid": "0f40196a-78bb-11e8-bac7-005056865aac", "agent address": "192.168.1.139", "agent name": "server001", "cambria.partition": "server001", "community": "", "community len": 0, "epoch_serno": 15299605440000, "protocol version": "v2c", "time received": 1529960544.4896748, "trap category": "com.companyname.dcae.dmaap.location.DCAE-COLLECTOR-UCSNMP", "sysUptime": "751564798", "notify OID": "1.3.6.1.4.1.999.0.1", "notify OID len": 9, "varbinds": [{"varbind_oid": "1.3.6.1.4.1.999.0.1.1", "varbind_type": "OctetString", "varbind_value": "TEST TRAP"}]}
273     2018-06-25T21:02:24,496|post_dmaap|snmptrapd||||DETAILED|100||post_data_enclosed: {"uuid": "0f40196a-78bb-11e8-bac7-005056865aac", "agent address": "192.168.1.139", "agent name": "server001", "cambria.partition": "server001", "community": "", "community len": 0, "epoch_serno": 15299605440000, "protocol version": "v2c", "time received": 1529960544.4896748, "trap category": "com.att.dcae.dmaap.IST3.DCAE-COLLECTOR-UCSNMP", "sysUptime": "751564798", "notify OID": "1.3.6.1.4.1.999.0.1", "notify OID len": 9, "varbinds": [{"varbind_oid": "1.3.6.1.4.1.999.0.1.1", "varbind_type": "OctetString", "varbind_value": "TEST TRAP"}]}
274
275
276 Platform Status
277 ^^^^^^^^^^^^^^^
278
279 A permanent (left to user to archive/compress/etc) status file is maintained in the file referenced by:
280
281     **perm_status_file**
282
283 .. code-block:: json
284
285         "perm_status_file": "snmptrapd_status.log",
286
287 Combined with **runtime_base_dir** and **log_dir** settings from snmptrapd.json, the perm_status_file in default installations
288 can be found at:
289
290 .. code-block:: bash
291
292         /opt/app/uc/logs/snmptrapd_stats.log