APIs
This section covers the details of the APIs supported by Metering microservices.
Metering microservice contains the following.
Configuration APIs
GET/v1.0.0/metrics/configurations/applications/{applicationId}?
{
"items": [
{
"configId": 0,
"resourceId": "ACCOUNTS",
"metricType": "COUNT",
"statisticsType": "C",
"description": "string",
"additionaldata": {
"additionalProp1": "string",
"additionalProp3": "string",
"additionalProp2": "string"
}
}
]
}
POST/v1.0.0/metrics/configurations/applications/{applicationId}
{
"configId": 1,
"resourceId": "CONTRACTS",
"metricType": "COUNT",
"statisticsType": "C",
"description": "string",
"additionaldata": {
"additionalProp1": "string",
"additionalProp2": "string",
"additionalProp3": "string"
}
}
{
"configId": "1",
"applicationId": "KONY_UI",
"metricResourceId": "CONTRACTS",
"status": "Created"
} GET/v1.0.0/metering/configurations/{configurationId}
{
"configId": 0,
"resourceId": "CONTRACTS",
"metricType": "COUNT",
"statisticsType": "D",
"description": "string",
"additionaldata": {
"additionalProp1": "string",
"additionalProp3": "string",
"additionalProp2": "string"
}
}
DELETE/v1.0.0/metering/configurations/{configurationId}
{
"configId": "1",
"status": "Deleted"
} PUT/v1.0.0/
{
"applicationId": 0,
"resourceId": "CONTRACTS",
"metricType": "COUNT",
"statisticsType": "D",
"description": "string",
"additionaldata": {
"additionalProp1": "string",
"additionalProp2": "string",
"additionalProp3": "string"
}
}
{
"configId": "0",
"applicationId": "INFINITY",
"metricResourceId": "CONTRACTS",
"status": "updated"
} Logging APIs
There are two APIs to the logging part. The functionality of the logging APIs is to log the metering passed to this API. This section contains a GET and POST for storing and retrieving the information.
GET/v1.0.0/metrics/applications/INFINITY/?fromDate=2020-03-10&toDate=2020-03-10&resourceId=CONTRACTS&metricId=holdings
{
"items": [
{
"resourceId": "CONTRACTS",
"metricId": "holdings",
"meteredDate": "2020-03-10 00:00:00.0",
"usedCount": 0,
"isIncremental": true,
"additionaldata": {
"additionalProp1": "test",
"additionalProp3": "string",
"additionalProp2": "string"
}
}
]
}
POST/v1.0.0/metrics/applications/{applicationId}?requestId=f732bf06-300d-4719-8775-08dd580419d8
{
"items": [
{
"resourceId": "CONTRACTS",
"metricId": "holdings",
"meteredDate": "2020-03-10 00:00:00.0",
"usedCount": 0,
"isIncremental": true,
"additionaldata": {
"additionalProp1": "test",
"additionalProp3": "string",
"additionalProp2": "string"
}
}
]
}
Statistics APIs
GET/v1.0.0/metrics/applications/{applicationId}/statistics?fromDate=2020-03-10&toDate=2020-03-10
{
"items": [
{
"applicationId": "INFINITY",
"resourceId": "CONTRACTS",
"metricId": "holdings",
"meteredDate": "2020-03-10",
"totalUsageCount": 25
},
{
"applicationId": "INFINITY",
"resourceId": "CONTRACTS",
"metricId": "holdings",
"meteredDate": "2020-03-10",
"totalUsageCount": 87
},
{
"applicationId": "INFINITY",
"resourceId": "CONTRACTS",
"metricId": "holdings",
"meteredDate": "2020-03-10",
"totalUsageCount": 99
}
]
}
Scheduler for Metrics
A Scheduler is used to get the data from Temenos Transact and insert into the log table.
By default, the scheduler is part of the metering microservice package. This can be scheduled in different time for different systems. In the scheduled time, the scheduler calls the IRIS API which provides the payload to insert in to the metering table.
The API details are given below.
|
URI |
http://localhost:8080/ms-transact-api/api/v1.0.0/metrics/application/{applicationId} |
|
Path param |
applicationId |
|
Query param |
meteredDate |
|
Sample response |
[{
"resourceId": "CONTRACTS",
"metricId": "holdings",
"meteredDate": "2020-03-10",
"usedCount": 99,
"isIncremental": false,
"additionaldata": {
"additionalProp1": "test",
"additionalProp2": "string",
"additionalProp3": "string"
}
}]
|
The response of the above URI inturn calls the logging and statistics API implementation of the microservice internally.
Scheduler Enabler
The scheduler service is configured in the yml file, which has all the environment variable through which you get the deployment time information. Apart from the database connection parameters, the following two parameters are used.
- temn.metering.transact.base.url: http://localhost:8080/ms-transact-api/api/v1.0.0/metrics/application/{applicationId}
- temn.msf.scheduler.transact.cron.trigger.time: 0/120 * * * * ?
The above two variables are used to configure the base url and cron trigger time based on the requirement.
The properties for the j2EE deployment is maintained in a properties file. It has the following environment variables.
- temn.metering.transact.base.url: http://localhost:8080/ms-transact-api/api/v1.0.0/metrics/application/{applicationId}
- temn.msf.scheduler.transact.cron.trigger.time: 0/120 * * * * ?
The Scheduler for Metering Microservice is available in Aws Environment and you can set the cron trigger time of the scheduler.
Procedure:
- Log in to the AWS Console.
- Choose the CloudWatch service and rules in the context menu section.
- In the Cloud Watch rule, choose ms-metering-scheduler-rule and you can modify the trigger time for the metering scheduler.
The lambda function mapped to the scheduler is metering scheduler and it will be triggered based on the cron trigger time set in the cloud watch rule linked to the lambda function.
Now, you can check the information in the usage statistics table and cloudwatch logs whether the scheduler has run.
In this topic