/metric_assessor

Service for accessing devices metrics and events.

Primary LanguageJava

Metrics Assessor Build Status

Service for accessing devices metrics and events.

Run

Ensure that PostgreSql is accessible before running the service.
Postrges access url is specified in application.properties for spring.datasource.url

In docker

sudo ./gradlew build buildDocker -x test -x test_integration
sudo docker run -p 8080:8080 -t com.metric.assessor

In OS

./gradlew bootRun

Testing

Ensure, that local PostgreSql is accessible, before running tests.

./gradlew check

Protocol

GET /api/v1/sensors/{uuid}/events to get all events of the sensor.
Where:
uuid is the sensor's uuid.
Reply:

{
    "sensorUuid" : "<uuid>",
    "events" : 
    [
        {
            "type" : "<Type>",
            "at" : "<Date>",
            "temperature" : <Temperature>
        }
    ]
}

Where:
uuid is sensor's uuid String.
Type is the event's type String (TEMPERATURE_EXCEEDED).
at is a date of event in ISO_OFFSET_DATE_TIME format.
temperature is the temperature on the moment event was fired. It is double.

GET /api/v1/sensors/{uuid}/measurements to get sensor's statistics.
Where:
uuid is the sensor's uuid.
Reply:

{
    "sensorUuid" : "<uuid>",
    "averageLastHour" : <avg1h>
    "averageLast7Days" : <avg7d>
    "maxLast30Days" : <max30d>
}

Where:
uuid is sensor's uuid String.
avg1h is an average temperature for last hour.
avg7d is an average temperature for last 7 days.
max30d is a maximum temperature for last 30 days.