FIWARE 实体作为一组 KPI 属性

问题描述

Our system 需要返回分组在不同主题中的多个 KPI:

  • 人口普查:
    • 公民(居民人数)
    • 没有任何研究的公民
    • ...
  • 问讯处
  • 税收
    • 在线支付
    • 窗口支付
    • ...

据我所知,每个主题都有一个实体,每个 KPI 都是一个 KeyPerformanceIndicator 属性。例如:这可能类似于:

{
    "description": "Census information system","dataProvided": {
        "entities": [
            {
                "idPattern": ".*"
            }
        ],"attrs":[    //THIS SEEMS AN INTERESTING APPROACH,BUT SADLY ALSO INVALID
            {
                "name": "citizens","type": "KeyPerformanceIndicator"
            },{
                "name": "citizens_without_studies",//...
        ]
    },"provider": {
        "http": {
            "url": "http://myhost/v2/census"
        }
    }
}

(TL;DR: "attrs" 只支持字符串,所以不能返回复杂/数据建模类型,比如 KPI)

把这个好主意放在一边,解决这个问题的好方法是什么?

每个 KPI 都必须是一个实体吗?

NGSI-LD 是我要找的吗?

解决方法

我认为您的情况可以在 NGIv2 中解决。让我试着解释一下。

每个 KPI 都必须是一个实体吗?

是的。这是根据 KPIs datamodel 对 KPI 建模的常用方法。每个 KPI 都被建模为 KeyPerformanceIndicator 类型的实体。

能否对 KPI 进行分类?

是的。您可以使用 category 属性来做到这一点。

例如,您可以通过以下方式建模“税务信息”类别的 KPI“在线支付”:

{  
  "id": "OnlinePayments","type": "KeyPerformanceIndicator",...
  "category": ["taxInformation"],...
}  

请注意,category 是一个数组,因此给定的 KPI 可能属于多个类别(尽管在您的用例中,每个 KPI 似乎都属于一个类别,因此您不需要此功能)

如何获得属于给定类别的 KPI?

您可以为此使用常规的 Orion Context Broker 过滤功能。例如,要获取类别 taxInformation 中的所有 KPI,您可以使用此键:

GET /v2/entitites?type=KeyPerformanceIndicator&q=category:taxInformation

或订阅中的此表达式:

{
    "subject": {
        "entities": [
            {
                "idPattern": ".*","type": "KeyPerformanceIndicator"
            }
        ],"condition": {
            ...
            "expression": {
               "q": "category:taxInformation"
            }
         }
    },...
}
,

我想关于如何为 KPI 创建有效负载的一些见解在 smart data models 计划中用于 keyPerformanceIndicators

对于 NGSI v2,您可以看到 key values 格式和 normalized format 格式的一些负载。 (NGSI LD 也有)

specification of the key performance indicator data modeljson schema for the validation 也可用。