Antonio Moreno Borras
Antonio Moreno Borras

Reputation: 81

fiware-perseo CEP is not sending emails I can't see the rules in mongo but when i run get rules yes

When I set a rule to send an email with fiware-perseo cep when an attribute change, I don't get the email and if I look for the rule in Mongo, I can't see it, but if I execute get rules from API get, I see the rule. I use docker and I don't know if I have set up the .yml file correctly to set up perseo-core, perseo-fe, and orion, I have followed the guide:

https://perseo.readthedocs.io/en/latest/admin/

I don't know if in Orion I have to set up anything to point at Perseo. I provide the code in the code section.

A part from the .yml code, I have created this Rule through the API:

    {
    "name": "prueba1",
    "text": "select *, \"prueba1\" as ruleName ,ev.temperature? as temperature, ev.id? as id from pattern [every ev=iotEvent(cast(cast(temperature?,String),float)>45.5 and type=\"AirQualityObserved\")]",
    "action": {
        "type": "email",
        "template": "Entity ${id} temperature is ${temperature}",
        "parameters": {
            "to": "[email protected]",
            "from": "[email protected]",
            "subject": "High Temp"
        }
    }
}

version: "3.1"
services:
  mongo-db:
    image: mongo:3.2
    hostname: mongo-db
    container_name: fiware-mongo-db
    ports:
        - "27017:27017"
    expose:
        - "27017"    
    networks:
        - smartcity

    volumes:
      - "mongo-db:/data"
  mysql-db:
    image: mysql:5.7
    hostname: mysql-db
    container_name: fiware-mysql-db
    expose:
      - "3306"
    ports:
      - "3306:3306"
    networks:
      - smartcity
    environment:
      - "MYSQL_ROOT_PASSWORD=1234"
      - "MYSQL_ROOT_HOST=%"
    volumes:
      - mysql-db:/var/lib/mysql"
  orion:

    image: fiware/orion:latest
    hostname: orion
    container_name: fiware-orion-mongo
    networks:
        - smartcity
    expose:
        - "1026"
    ports:
        - "1026:1026"
    command: -dbhost mongo-db -logLevel DEBUG
    healthcheck:
      test: curl --fail -s http://localhost:1026/version || exit 1

  cygnus:
    image: fiware/cygnus-ngsi:1.10.0
    hostname: cygnus
    container_name: fiware-cygnus
    depends_on:
        - mysql-db
        - mongo-db
    networks:
        - smartcity
    expose:
      - "5080"

    ports:
      - "5050:5050"
      - "5051:5051"
      - "5054:5054"
      - "5080:5080"

    environment:
        - "CYGNUS_MULTIAGENT=true" # Whether to persist data into multiple databases.
        - "CYGNUS_MONGO_HOSTS=mongo-db:27017" # Comma separated list of Mongo-DB servers which Cygnus will contact to persist historical context data
        - "CYGNUS_MONGO_DATA_MODEL=dm-by-service-path" # data_model
        - "CYGNUS_MONGO_ATTR_PERSISTENCE=column" # data_model
        - "CYGNUS_MONGO_DB_PREFIX=sti-"
        - "CYGNUS_MONGO_USER=root"
        - "CYGNUS_MONGO_PASS=example"
        - "CYGNUS_STH_DB_PREFIX=sth-"
        - "CYGNUS_LOG_LEVEL=DEBUG" # The logging level for Cygnus
        - "CYGNUS_SERVICE_PORT=5050" # Notification Port that Cygnus listens when subcribing to context data changes
        - "CYGNUS_API_PORT=5080" # Port that Cygnus listens on for operational reasons
        - "CYGNUS_MYSQL_HOST=mysql-db" # Hostname of the MySQL server used to persist historical context data 
        - "CYGNUS_MYSQL_PORT=3306" # Port that the MySQL server uses to listen to commands
        - "CYGNUS_MYSQL_USER=root" # Username for the MySQL database user
        - "CYGNUS_MYSQL_PASS=1234" # Password for the MySQL database user
        - "CYGNUS_MYSQL_DATA_MODEL=dm-by-service-path" # data_model
        - "CYGNUS_MYSQL_ATTR_PERSISTENCE=row"

    healthcheck:
      test: curl --fail -s http://localhost:5080/v1/version || exit 1

  iot-agent:
    image: fiware/iotagent-ul:1.8.0
    hostname: iot-agent
    container_name: fiware-iot-agent
    networks:
        - smartcity
    ports:
        - "4041:4041"
        - "7896:7896"
    environment:
        - "IOTA_CB_HOST=orion" # name of the context broker to update context
        - "IOTA_CB_PORT=1026" # port the context broker listens on to update context
        - "IOTA_NORTH_PORT=4041"
        - "IOTA_REGISTRY_TYPE=mongodb" #Whether to hold IoT device info in memory or in a database
        - "IOTA_LOG_LEVEL=DEBUG" #The log level of the IoT Agent
        - "IOTA_TIMESTAMP=true"
        - "IOTA_MONGO_HOST=mongo-db" # The host name of ongoDB
        - "IOTA_MONGO_PORT=27017" # The port mongoDB is listening on
        - "IOTA_MONGO_DB=iot-smartcity" # The name of the database used in mongoDB
        - "IOTA_HTTP_PORT=7896" # The port used for device traffic over HTTP
        - "IOTA_PROVIDER_URL=http://iot-agent:4041"
    healthcheck:
      test: curl --fail -s http://localhost:4041/iot/about || exit 1

  sth-comet:
    image: fiware/sth-comet
    hostname: sth-comet
    container_name: fiware-sth-comet
    networks:
        - smartcity
    ports:
        - "8666:8666"
    environment:
        - STH_HOST=0.0.0.0
        - STH_PORT=8666
        - DB_PREFIX=sth-commet-
        - "DB_URI=mongo-db:27017"
        - LOGOPS_LEVEL=DEBUG
  perseo-core:
    image: fiware/perseo-core
    hostname: perseo-core
    container_name: fiware-perseo-core
    depends_on:
        - mongo-db
        - orion
    networks:
        - smartcity
    ports:
        - "8080:8080"
    environment:

        - PERSEO_FE_URL=http://perseo-fe:9090
        - MAX_AGE=6000

  perseo-front:
    image: fiware/perseo
    hostname: perseo-fe
    container_name: fiware-perseo-fe
    networks:
        - smartcity
    ports:
        - "9090:9090"
    depends_on:
         - perseo-core
    environment:
        - PERSEO_ENDPOINT_HOST=perseo-core
        - PERSEO_ENDPOINT_PORT=8080
        - PERSEO_MONGO_HOST=mongo-db
        - PERSEO_MONGO_URL=http://mongo-db:27017
        - PERSEO_MONGO_ENDPOINT=mongo-db:27017  
        - PERSEO_ORION_URL=http://orion:1026/
        - PERSEO_LOG_LEVEL=debug
        - PERSEO_CORE_URL=http://perseo-core:8080
        - PERSEO_SMTP_SECURE=true
        - PERSEO_MONGO_USER:"root"
        - PERSEO_MONGO_PASSWORD:"example"
        - PERSEO_SMTP_HOST=mail.someplace.com
        - PERSEO_SMTP_PORT=25
        - [email protected]
        - PERSEO_SMTP_AUTH_PASS=xxxxx
        - PERSEO_NOTICES_PATH='/notices'
        - PERSEO_RULES_PATH='/rules'

    networks:
        - smartcity        

volumes:
  mongo-db: 
  mysql-db:

networks:
  smartcity:
    driver: bridge

I want to be able to send an email when an attribute exceeds a threshold, now it is not working.

Upvotes: 1

Views: 278

Answers (2)

Antonio Moreno Borras
Antonio Moreno Borras

Reputation: 81

the correct is: http://perseo-fe-ip:9090/rules, with that it works.

Store the rule in mongodb and fire the rule properly.

Upvotes: 0

fgalan
fgalan

Reputation: 12294

Looking to Perseo configuration it seems you have left the configuration template for SMTP, e.g:

- PERSEO_SMTP_HOST=mail.someplace.com

Note mail.someplace.com is just an example but it is not a real SMTP server. You should adjust this (and maybe other PERSEO_SMTP_xxx parameters) configuration parameters to fit the ones in your SMTP server.

EDIT: in order to check the rule condition and know if the problem is in the rule condition or in your SMTP configuration, you could try the same rule condition but with a simpler action (for instance, doing a HTTP action, combined with some kind of echo-ing service like RequestBin)

EDIT2: msg=missing subservice header, msg=missing service header typically mean that the incoming request doesn't have the fiware-service and fiware-servicepath HTTP headers in which multitenancy is based. The FIWARE multitenancy model is described here.

Upvotes: 1

Related Questions