swagger-stats
swagger-stats copied to clipboard
How to connect to elasticsearch and kibana
Hi,
Do you have a step(doc) to connect to elasticsearch like Prometheus
Hi! To connect to ElasticSearch, specify ES URL in options when initializing swagger-stats:
var swsOptions = {
name: 'swagger-stats-spectest',
version: '0.95.0',
hostname: "hostname",
ip: "127.0.0.1",
swaggerSpec:swaggerSpec,
uriPath: '/swagger-stats',
durationBuckets: [10, 25, 50, 100, 200],
requestSizeBuckets: [10, 25, 50, 100, 200],
responseSizeBuckets: [10, 25, 50, 100, 200],
apdexThreshold: 25,
elasticsearch = 'http://localhost:9200'
};
app.use(swStats.getMiddleware(swsOptions));
The schema (index template) of the documents written to ElasticSearch by swagger-stats is available in /schema/elasticsearch/api_index_template.json
Will be adding more docs ...
i use
var swStats = require('swagger-stats');
// var apiSpec = require('swagger.json');
webApp.use(swStats.getMiddleware({
elasticsearch: "http://xx.xx.xx.xx:9200"
}));
but the' http://xx.xx.xx.xx:30001/swagger-stats/ui#sws_rates'
when i restart app server the data is disappear
How to persist data?
Hi ! The data in built-in telemetry dashboard is not persisted across restarts. Swagger-stats shows built-in dashboard based on in-memory data only. This is to ensure that built-in telemetry does not depend on any external server. Now, if you have ElasticSearch enabled, swagger-stats wrintes info about each API requests to ElasticSearch. This data is persistent. You can use Kibana to analyze data written into ElasticSearch. You may load provided Kibana dashboard, or create your own, and of course use Discover in Kibana.
@sv2 thk u for woking all very much
How come memory and cpu stats are not sent to ES? Would be really nice instead of only Prometheus. Thanks.
Makes sense, will do. Thanks !
#85 - for tracking
@sv2 "You may load provided Kibana dashboard," Could you explain how to load the provided Kibana dashboard please ?