Metrics microservice
This is the metrics microservice. It keeps list of metrics.
This microservice is designed to manage various metrics characterizing the operation of a process. Each metric has the following characteristics:
- metric name
- up to 3 types of measurements (in string format)
- date and time is a numerical value characterizing the metric
When adding or updating a metric, statistics on the metric are automatically calculated for different time horizons (you can specify the depth of the horizon) with the calculation of the average, maximum, minimum and accumulated values within each of them.
Data access is provided through a set of API functions
The microservice currently supports the following deployment options:
- Deployment platforms: Standalone Process
- External APIs: HTTP/REST
- Persistence: Memory, Flat Files, MongoDB
This microservice has no dependencies on other microservices. Quick Links:
- Download Links
- Development Guide
- Deployment Guide
- Configuration Guide
- Client SDKs
- Communication Protocols
Contract
Logical contract of the microservice is presented below. For physical implementation (HTTP/REST, GRPC, Lambda, etc.), please, refer to documentation of the specific protocol.
// Create or update metric struct// Metric definition struct// Metric value struct// Values of metric// Time horizons
Download
Right now the only way to get the microservice is to check it out directly from github repository
git clone git@github.com:pip-services-infrastructure/pip-services-metrics-node.git
Pip.Service team is working to implement packaging and make stable releases available for your as zip downloadable archieves.
Run
Add config.yaml file to the root of the microservice folder and set configuration parameters. As the starting point you can use example configuration from config.example.yaml file.
Example of microservice configuration
{ ---- descriptor: "pip-services-commons:logger:console:default:1.0" level: "trace" - descriptor: "pip-services-metrics:persistence:file:default:1.0" path: "./data/blobs" - descriptor: "pip-services-metrics:controller:default:default:1.0" - descriptor: "pip-services-metrics:service:http:default:1.0" connection: protocol: "http" host: "0.0.0.0" port: 3000}
For more information on the microservice configuration see Configuration Guide.
Start the microservice using the command:
node run
Use
Inside your code get the reference to the client SDK
;
Define client configuration parameters.
// Client configuration;client.configurehttpConfig;
Instantiate the client and open connection to the microservice
// Create the client instanceclient = new MetricssHttpClientV1; // Connect to the microserviceclient.opennull,
Now the client is ready to perform operations:
Update if exist metric or create otherwise:
client.updateMetric null, MetricUpdateV1 , TimeHorizonV1.Hour, ;
Update if exist metrics or create otherwise::
client.updateMetrics null, , TimeHorizonV1.Hour, ;
Get metrics by filter:
client.getMetricsByFilternull, FilterParams.fromTuples"name", "metric1", new PagingParams,;
Get all metrics definitions:
client.getMetricDefinitions null,;
Get metric definition by name:
client.getMetricDefinitionByName null, "metric2", ;
Acknowledgements
This client SDK was created and currently maintained by Sergey Seroukhov and Levichev Dmitry.