Device logs sent to a server and published via Google cloud pub/sub.

Arivo can send these logs to any number of custom subscriptions.

Arivo can specify what logs are sent to which subscription.

# Sending logs to a topic in your gcloud project

If you have your own gcloud project and want to create a subscription there, Arivo can publish the logs to a topic in your project.

In this case, the topic must exist in your project and you need to provide the project name and topic name

You must also provide the Pub/Sub Publisher role to a specified Arivo gcloud service account.

You can manage any subscription to the topic yourself.

# Receiving logs on a HTTPS endpoint via push subscription

gcloud allows for creating push subscriptions (opens new window) which send any messages to a given HTTPS endpoint.

Arivo can create push subscription to send messages to a specified HTTPS endpoint.

This will require you to set up a server to receive these messages and provide Arivo with the url to your HTTPS endpoint.

Messages will include an Authentication header as described here (opens new window).

Verifying the Authentication header is described here (opens new window).

# Message structure

The data inside a message received from gcloud Pub/Sub is structured as follows:

{
  "resource": <The ID of the resource that sent the message>
  "topic": <The internal pub/sub topic. Not to be confused with the gcloud pub/sub topic "session" for session finish messages>
  "payload": <The actual message data, payload for session finish message is described below>
}

# Session message for statistics

For payment statistics there are 3 important messages:

  • Session finish: Is sent when a parking session is finished (Car left the parking lot)
  • Cost Table update: Is sent when the cost table of a finished session is altered (either by changing the costs or by adding payments)
  • Session delete: Is sent when a session is marked as incorrect.
  • On Session Finish message: Store the data of the parking session you are interested in so that it can be referenced via the session id
  • On Cost Table Update message: Update the data of the corresponding parking session
  • On Session Delete: Remove the data of the corresponding parking session.

# Other session messages

There are additional session messages which can be ignored in statistics or for accounting:

  • "type": "start": Parking session was started. Costs / Payments are not know yet
  • "type": "transfer": Parking access was changed. This can only happen for unfinished parking sessions
  • "type": "incomplete": An open parking session was marked as incomplete and this session is incorrect and cannot be billed. This can only happen for unfinished parking sessions
  • "type": "exit_without_entry": A vehicle left the parking lot without an open parking session. This session is incorrect and cannot be billed

# Common Data in Messages

# MovementData ("entry_data" and "exit_data" in finish message)

{
  "gate": <technical name of gate where vehicle entered (manually created if not given or null), type: Optional[string]>,
  "vehicle_data": <data of vehicle (manually created if not given or null), type: Optional[VehicleData]>
} 

# VehicleData ("vehicle_data" in MovementData)

{
  "plate": <license plate as read (including spaces and other delimiters), type: string>,
  "country": <country of license plate as international vehicle registration code, type: string>
}

# CostTable ("cost_table" in finish message)

{
  "amount_total": <amount of total costs of this parking session in cents, type: integer>,
  "amount_payed": <amount of payments for this parking session in cents, type: integer>
}

open_costs = cost_table["amount_total"] - cost_table["amount_payed"]

# Data in Session finish message

{
  "type": "finish",
  "timestamp": <utc timestamp of when the message was sent, type: float>,
  "id": <id of parking session, type: string (uuid)>,
  "entry_time": <session start time, type: string (formatted as naive ISO 8601 datetime string (UTC))>,
  "exit_time": <session end time, type: string (formatted as naive ISO 8601 datetime string (UTC))>,
  "clearing": <if given and not null, costs are booked on a user account, type: Optional[string]>,
  "entry_data": <data of enter movement, type: MovementData>,
  "exit_data": <data of exit movement, type: MovementData>,
  "cost_table": <datastructure of costs and payments, type CostTable>
}

# Example

{
    "type": "finish",
    "timestamp": 1669207872.980452,
    "id": "3de770a0-0a91-4a71-9119-faf669249647",
    "entry_time": "2022-11-23T12:50:55.189834",
    "exit_time": "2022-11-23T12:51:12.954304",
    "entry_data":
    {
        "gate": "einfahrt",
        "vehicle_data":
        {
            "plate": "G ARIVO 1",
            "country": "A"
        }
    },
    "exit_data":
    {
        "gate": "ausfahrt",
        "vehicle_data":
        {
            "plate": "G ARIVO 1",
            "country": "A"
        }
    },
    "cost_table":
    {
        "amount_total": 150,
        "amount_payed": 150
    },
}

# Data in Cost Table update message

only difference is type and some additional internal information

{
  "type": "cost_table_update",
  "timestamp": <utc timestamp of when the message was sent, type: float>,
  "id": <id of parking session, type: string (uuid)>,
  "entry_time": <session start time, type: string (formatted as naive ISO 8601 datetime string (UTC))>,
  "exit_time": <session end time, type: string (formatted as naive ISO 8601 datetime string (UTC))>,
  "clearing": <if given and not null, costs are booked on a user account, type: Optional[string]>,
  "entry_data": <data of enter movement, type: MovementData>,
  "exit_data": <data of exit movement, type: MovementData>,
  "cost_table": <datastructure of costs and payments, type CostTable>
}

# Data in Session Delete message

only difference is type and some additional internal information

{
  "type": "delete",
  "timestamp": <utc timestamp of when the message was sent, type: float>,
  "id": <id of parking session, type: string (uuid)>,
  "entry_time": <session start time, type: string (formatted as naive ISO 8601 datetime string (UTC))>,
  "exit_time": <session end time, type: string (formatted as naive ISO 8601 datetime string (UTC))>,
  "clearing": <if given and not null, costs are booked on a user account, type: Optional[string]>,
  "entry_data": <data of enter movement, type: MovementData>,
  "exit_data": <data of exit movement, type: MovementData>,
  "cost_table": <datastructure of costs and payments, type CostTable>
}