LiveSwitch Usage Service releases.
512
The LiveSwitch Usage Service collects connection and client events from the LiveSwitch servers and aggregates daily usage based on them.
Do the following:
sudo docker network create liveswitch
sudo docker run -d \
--env POSTGRES_PASSWORD='password' \
--network liveswitch \
--publish 5432:5432 \
--restart always \
--name postgres \
postgres
sudo docker exec -it postgres \
psql "postgresql://postgres:password@localhost" -c "CREATE DATABASE liveswitch_events;"
sudo docker exec -it postgres \
psql "postgresql://postgres:password@localhost" -c "GRANT ALL PRIVILEGES ON DATABASE liveswitch_events TO postgres;"
sudo docker exec -it postgres \
psql "postgresql://postgres:password@localhost" -c "CREATE DATABASE liveswitch_usage;"
sudo docker exec -it postgres \
psql "postgresql://postgres:password@localhost" -c "GRANT ALL PRIVILEGES ON DATABASE liveswitch_usage TO postgres;"
sudo docker run -d \
--env ConnectionStrings:PostgresEvents='User ID=postgres;Password=password;Host=postgres;Port=5432;Database=liveswitch_events' \
--env ConnectionStrings:PostgresUsage='User ID=postgres;Password=password;Host=postgres;Port=5432;Database=liveswitch_usage' \
--network liveswitch \
--publish 80:80 \
--restart always \
--name liveswitch-usage-service \
frozenmountain/liveswitch-usage-service
NOTE: All of these webhook events must be configured and sent to the usage service for the usage aggregation to work.
The events can be configured using environment variables on your Gateway or using the LiveSwitch Server Console.
To configure using environment variables, set the following environment variables on your Gateway container:
Applications:0:ApplicationId='my-app-id'
Applications:0:SharedSecret='--replaceThisWithYourOwnSharedSecret--'
Applications:0:Channels:0:ChannelIdPattern='*'
Applications:0:Channels:0:Webhooks:0:Name='LiveSwitch Usage Service'
Applications:0:Channels:0:Webhooks:0:Events:0='connection.connected'
Applications:0:Channels:0:Webhooks:0:Events:1='connection.closed'
Applications:0:Channels:0:Webhooks:0:Events:2='connection.failed'
Applications:0:Channels:0:Webhooks:0:Events:3='connection.initializing'
Applications:0:Channels:0:Webhooks:0:Events:4='channel.client.left'
Applications:0:Channels:0:Webhooks:0:Batch=true
Applications:0:Channels:0:Webhooks:0:Reliable=true
Applications:0:Channels:0:Webhooks:0:Url='http://localhost/events'
To create and configure the webhooks using the LiveSwitch Server Console, see Webhook Configuration.
NOTE: When configuring events using the LiveSwitch Server Console, please make sure the Batch and Reliable checkboxes are checked.
The swagger interface can be found by going to the /swagger path of your LiveSwitch Usage Service (e.g. http://localhost/swagger). There are two public endpoints you can access from this interface.
This endpoint will manually start an aggregation for the specified date. The LiveSwitch Usage Service automatically aggregates at the end of the day so calling this endpoint is only necessary if you want to generate daily usage before the end of the day.
This endpoint returns daily usage. The request can be filtered by an Application ID, as well as start and end dates.
The daily usage output is JSON formatted as follows
[
{
"applicationId": "ApplicationId",
"startTimestamp": "2023-01-01T00:00:00Z",
"endTimestamp": "2023-01-01T23:59:59Z",
"messagesSent": 518
"messagesReceived": 37,
"messageBytesSent": 46718,
"messageBytesReceived": 532,
"participantMinutes": {
"0": 968,
"307200": 1532,
"921600": 325,
"2073600": 45,
},
"peakConcurrentUsers": 17,
"createdOn": "2023-01-02T00:00:00.809108Z",
"signature": ""
}
]
The participant minutes are separated by resolution (width * height). Common resolutions are:
The signature property at the end is required when sending the usage information to the LiveSwitch team. It is enabled as a parameter to the /usage endpoint.
Content type
Image
Digest
sha256:dfdb7e2b2…
Size
89 MB
Last updated
about 3 years ago
docker pull frozenmountain/liveswitch-usage-service