A plugin can create statistics (metrics) that are accessible in the same way as Traffic Server core statistics. In general monitoring the behavior of plugins in production is easier to do in this way in contrast to processing log files.
These APIs are deprecated as of ATS v10.0.0, and will likely be removed in v11. Instead, use the new APIs in Metrics.h diretly.
int TSStatCreate(const char *name, TSRecordDataType type, TSStatPersistence persistence, TSStatSync sync_style)¶
typedef void (*TSRecordDumpCb)(TSRecordType *type, void *edata, int registered, const char *name, TSRecordDataType type, TSRecordData *datum)¶
A plugin statistic is created by
TSStatCreate(). The name must be globally unique and
should follow the standard dotted tag form. To avoid collisions and for easy of use the first tag
should be the plugin name or something easily derived from it. Currently only integers are supported
therefore type must be
TS_RECORDDATATYPE_INT. The return value is
the index of the statistic. In general this should work but if it doesn’t it will
particular, creating the same statistic twice will fail in this way, which can happen if statistics
are created as part of or based on configuration files and Traffic Server is reloaded.
TSStatFindName() locates a statistic by name. If found the function returns
TS_SUCCESS and the value pointed at by idx_ptr is updated to be the index of the
statistic. Otherwise it returns
A group of records can be examined via
TSRecordDump(). A set of records is specified and the
iterated over. For each record in the set the callbac callback is invoked.
The record type.
Callback context. This is the edata value passed to
A flag indicating if the value has been registered.
The name of the record. This is nul terminated.
The storage type of the data in the record.
The record data.
Adding Statistics TSAPI(3ts)