swagger-stats icon indicating copy to clipboard operation
swagger-stats copied to clipboard

How to connect to elasticsearch and kibana

Open mnajmi86 opened this issue 6 years ago • 8 comments

Hi,

Do you have a step(doc) to connect to elasticsearch like Prometheus

mnajmi86 avatar Apr 23 '18 08:04 mnajmi86

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 ...

sv2 avatar Apr 23 '18 14:04 sv2

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' rtx when i restart app server the data is disappear How to persist data?

dduo518 avatar Aug 02 '18 01:08 dduo518

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 avatar Aug 02 '18 04:08 sv2

@sv2 thk u for woking all very much

dduo518 avatar Aug 02 '18 05:08 dduo518

How come memory and cpu stats are not sent to ES? Would be really nice instead of only Prometheus. Thanks.

charlie-harvey avatar Dec 05 '19 22:12 charlie-harvey

Makes sense, will do. Thanks !

sv2 avatar Dec 06 '19 01:12 sv2

#85 - for tracking

sv2 avatar Dec 06 '19 01:12 sv2

@sv2 "You may load provided Kibana dashboard," Could you explain how to load the provided Kibana dashboard please ?

jungrylls avatar Jan 26 '23 09:01 jungrylls