tanimientras
tanimientras

Reputation: 25

FIWARE entity as a group of KPI attributes

Our system needs to return several KPIs grouped in different topics:

To my understanding, it would make sense to have an entity for each topic and each KPI being a KeyPerformanceIndicator attribute. eg: This could work similar to:

{
    "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",
                "type": "KeyPerformanceIndicator"
            },
            //...
        ]
    },
    "provider": {
        "http": {
            "url": "http://myhost/v2/census"
        }
    }
}

(TL;DR: "attrs" supports strings only, so can't return complex/data modeled types, like KPI)

Setting this happy idea aside, what it would be a good approach to solve this?

Must each KPI be an entity?

Is NGSI-LD what I'm looking for?

Upvotes: 1

Views: 101

Answers (2)

Jose Manuel Cantera
Jose Manuel Cantera

Reputation: 853

If what you are trying to accomplish is to offer an NGSI interface for your KPI data, you can just create your own adaptor on top of your database that offers a REST interface compliant with NGSI-LD and such service can just return entities of type KeyPerformanceIndicator. Then, you can federate it to a Context Broker with a simple registration i.e. for entities of type KeyPerformanceIndicator. And that's all.

The usage of Linked Data would be recommendable as well, so I would go for NGSI-LD, as it has been officially endorsed by ETSI.

Upvotes: 0

fgalan
fgalan

Reputation: 12294

I think your case can be solved in NGIv2. Let my try to explain.

Must each KPI be an entity?

Yes. That's the usual way of modelling KPIs according to the KPIs datamodel. Each KPI is modeled as an entity of type KeyPerformanceIndicator.

Can KPIs be categorized?

Yes. You can use the category attribute to do that.

For instance, you can have an KPI "Online payments" of category "Tax Information" modeled this way:

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

Note that category is an array, so a given KPI could belong to more than one category (although in your use case it seems that each KPI belongs to exactly one category so you don't need this feature)

How can I get KPIs that belong to a given category?

You can use regular Orion Context Broker filtering features for that. For instance, to get all KPIs in category taxInformation you could use this key:

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

or this expression in subscriptions:

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

Upvotes: 2

Related Questions