fiware-perseo CEP没有发送电子邮件,我在mongo中看不到规则,但是当我运行时获取规则是

时间:2019-05-09 10:41:47

标签: fiware-orion fiware-cep

当我设置规则以在属性更改时发送带有fiware-perseo cep的电子邮件时,我没有收到该电子邮件,如果我在Mongo中查找该规则,则看不到它,但是如果执行从API获取规则,我看到了规则。我使用docker,但我不知道是否已正确设置.yml文件来设置perseo-core,perseo-fe和orion,我已按照指南进行操作:

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

我不知道在Orion中是否必须设置任何指向Perseo的东西。 我在代码部分提供了代码。

.yml代码的一部分,我已经通过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": "antonio.moreno@someplace.com",
            "from": "avisos@someplace.com",
            "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
        - PERSEO_SMTP_AUTH_USER=someplace@someplace.com
        - PERSEO_SMTP_AUTH_PASS=xxxxx
        - PERSEO_NOTICES_PATH='/notices'
        - PERSEO_RULES_PATH='/rules'

    networks:
        - smartcity        

volumes:
  mongo-db: 
  mysql-db:

networks:
  smartcity:
    driver: bridge

我希望能够在属性超过阈值时发送电子邮件,现在它不起作用了。

2 个答案:

答案 0 :(得分:1)

对于Perseo配置,您似乎已经离开了SMTP的配置模板,例如:

- PERSEO_SMTP_HOST=mail.someplace.com

注意mail.someplace.com仅是示例,但不是真正的SMTP服务器。您应该调整此配置参数(可能还有其他PERSEO_SMTP_xxx参数)以适合SMTP服务器中的配置参数。

编辑:为了检查规则条件并知道问题是在规则条件中还是在您的SMTP配置中,您可以尝试相同的规则条件,但操作更简单(例如,doing a HTTP action,并结合了类似RequestBin的某种回声服务

EDIT2: msg=missing subservice header, msg=missing service header通常意味着传入请求没有基于fiware-servicefiware-servicepath的多租户HTTP标头。 here描述了FIWARE多租户模型。

答案 1 :(得分:0)

正确的是:http://perseo-fe-ip:9090/rules,它可以正常工作。

将规则存储在mongodb中并正确触发规则。