postgresqlfiwarefiware-cygnus

Fiware: Create Postgresql


Having Cygnus installed and running (subscribed to Orion). Orion receives notifications from client (via the ioagent). How do I start and create the postgresql databases for persistence?

Accessing fiware from remote server. Not sure what command to execute and start postgres.


Solution

  • There is a FIWARE Tutorial available about persisting historic data to PostGres

    Within docker-compose PostGres can be set-up as follows:

    postgres-db:
        image: postgres
        hostname: postgres-db
        container_name: db-postgres
        expose:
            - "5432"
        ports:
            - "5432:5432"
        networks:
            - default
        environment:
            - "POSTGRES_PASSWORD=password"
            - "POSTGRES_USER=postgres"
            - "POSTGRES_DB=postgres"
    

    The Cygnus configuration mirrors the PostGre config as shown:

    cygnus:
        image: fiware/cygnus-ngsi
        hostname: cygnus
        container_name: fiware-cygnus
        networks:
            - default
        depends_on:
            - postgres-db
        expose:
            - "5080"
        ports:
            - "5050:5050"
            - "5080:5080"
        environment:
            - "CYGNUS_POSTGRESQL_HOST=postgres-db"
            - "CYGNUS_POSTGRESQL_PORT=5432"
            - "CYGNUS_POSTGRESQL_USER=postgres"
            - "CYGNUS_POSTGRESQL_PASS=password"
            - "CYGNUS_SERVICE_PORT=5050"
            - "CYGNUS_API_PORT=5080"
            - "CYGNUS_POSTGRESQL_ENABLE_CACHE=true"
    

    The database instance should be instantiated when a subscription to Cygnus is fired.

    for example:

    curl -iX POST \
      'http://orion:1026/v2/subscriptions' \
      -H 'Content-Type: application/json' \
      -H 'fiware-service: <xxxxxx>' \
      -H 'fiware-servicepath: <yyyyyy>' \
      -d '{
      "description": "Notify Cygnus of all context changes",
      "subject": {
        "entities": [
          {
            "idPattern": ".*"
          }
        ]
      },
      "notification": {
        "http": {
          "url": "http://cygnus:5050/notify"
        },
        "attrsFormat": "legacy"
      },
      "throttling": 5
    }'