doc/developers/README.timeseries.md
In ntopng it's possible to extend the timeseries. To do it users need to change very few files.
Check for example asn:traffic_anomalies timeseries (Pro timeseries used to understand if any anomaly is found in an ASN):
Modify the scripts/lua/modules/timeseries/schemas/ts_{FREQUENCY}.lua file, by adding a new timeseries schema (like shown above), replacing {FREQUENCY} with the update frequency of the timeseries:
To the ts_utils.newSchema, 3 parameters are needed:
schema:addTag("ifid") schema:addTag("asn") schema:addMetric("anomaly")
schema:addTag(), add a new tag to the schema schema:addMetric(), add a metric to the schema
Then modify scripts/lua/modules/ts_{FREQUENCY}_dump_utils.lua by adding a new call to the ts_utils.append("asn:traffic_anomalies",{ifid=ifstats.id, asn=asn, anomaly=anomaly}, when). ts_utils.append needs:
Then to show the schema in the GUI modify the file that shows the timeseries charts (in the example above, 'scripts/lua/as_details.lua'). To do it add, add a new entry to the object 'LIST_OF_TIMESERIES' of the graph_utils.drawGraphs(ifId, schema, tags, zoom, asn_url, selected_epoch, {timeseries = LIST_OF_TIMESERIES}) function, having at least 2 parameters (like asn:traffic_anomalies):
NOTE: if a timeseries is changed during the time, the old rrd timeseries needs to be deleted and instead for influxdb the name of the schema needs to be added to the return of the function ts_utils.getPossiblyChangedSchemas() in the 'scripts/lua/modules/timeseries/ts_utils_core.lua' file,