0

Trying to create a schema with arrays for data retrieved from performance insights.

{
    "$schema": "http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#",
    "description": "Performance Insights",
    "self": {
        "vendor": "com.acme",
        "name": "performance_insights",
        "format": "jsonschema",
        "version": "1-0-3"
    },
    "type": "object",
    "properties": {
        "SeriesStartTime": {
            "type": "string",
            "format": "date-time",
            "description" : "timestamp"
        },
        "SeriesEndtime": {
            "type": "string",
            "format": "date-time",
            "description" : "timestamp"
        },
        "Identifier": {
            "description": "DataBase",
            "type": "string",
            "maxLength": 128
        },
        "MetricList": {
            "type": "array",
            "items":{
            "type": "object",
            "properties": {
                "Key": {
                    "type": "object",
                    "description": "Key Metric",
                    "properties": {
                        "Metric": {
                            "type": "string",
                            "description": "Load Avg"
                        },
                        "Dimensions": {
                            "properties": {
                                "tokenized_db": {
                                    "type": "string",
                                    "maxLength": 128
                                },
                                "tokenized_id": {
                                    "type": "string",
                                    "maxLength": 128
                                },
                                "tokenized_statement": {
                                    "type": "string"
                                }
                            }
                        }
                    }
                },                
                "DataPoints": {
                    "type": "array",
                    "items": {
                    "type": "object",
                    "properties": {
                        "Timestamp": {
                            "description" : "timestamp",
                            "type": "string",
                            "format": "date-time"
                        },
                        "Value": {
                            "description" : "Value",
                            "type": "number"
                        }
                    }
                }
                }
            }
        },
        "minItems": 1
    }
    
    },
    "additionalProperties": false
    
}

It lints ok then I send data to it:

{
      "schema": "iglu:com.acme/performance_insights/jsonschema/1-0-3",
      "data": {
        "SeriesStartTime": "2021-12-09T19:00:00-05:00",
        "SeriesEndtime": "2021-12-09T20:00:00-05:00",
        "Identifier": "db-5LHLHN5OGHFFFFMHRGDM",
        "MetricList": [
            {
                "Key": {
                    "Metric": "db.load.avg"
                },
                "DataPoints": [
                    {
                        "Timestamp": "2021-12-09T19:01:00-05:00",
                        "Value": 0.01818181818181818
                    },
                    {
                        "Timestamp": "2021-12-09T19:25:00-05:00",
                        "Value": 0.01818181818181818
                    }
                ]
            }]
    }
    }

I've pushed the schema to my repo I have push a couple others which work but not so complex as to receive array data.

Seems when I intentionally put the type wrong I see errors in my bad collector. When everything is correct as above I only see

schemaKey:"iglu:com.acme/performance_insights/jsonschema/1-0-3"
schemaCriterion:"iglu:com.snowplowanalytics.snowplow/payload_data/jsonschema/1-0-*"

As a failure.message

Any ideas ?

4

0 回答 0