opensearch-project / data-prepper

Data Prepper is a component of the OpenSearch project that accepts, filters, transforms, enriches, and routes data at scale.
https://opensearch.org/docs/latest/clients/data-prepper/index/
Apache License 2.0
238 stars 176 forks source link

Add dashboard inline asset to the blueprint #4657

Open YANG-DB opened 1 week ago

YANG-DB commented 1 week ago

Is your feature request related to a problem? Please describe. Today the blueprint contains a template field allowing to add an inline definition of the index template the ingestion should write into.

        ....
        template_content: >
          {
            "index_patterns": [
              "ss4o_metrics-*-*"
            ],
            "template": {
              "mappings": {
                "_meta": {
                ....

It would make much sense to add a similar capability to create a dashboard that shows the ingested data which corresponds to the data being ingested.

Describe the solution you'd like In a similar manner to the template field, add a dashboard_content field that is an embedded ndjson file. This part will call either the savedObject API of the Dashboards server or store the ndjson document directly in the .kibana index as a dashboard doc.

        ....
        dashboard_content: >
              {"attributes":{"description":"","kibanaSavedObjectMeta":{"searchSourceJSON":"{\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filter\":[],\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}"},"title":"ingest-services-metrics-count","uiStateJSON":"{}","version":1,"visState":"{\"title\":\"ingest-services-metrics-count\",\"type\":\"table\",\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"params\":{\"customLabel\":\"count\"},\"schema\":\"metric\"},{\"id\":\"2\",\"enabled\":true,\"type\":\"terms\",\"params\":{\"field\":\"serviceName\",\"orderBy\":\"1\",\"order\":\"desc\",\"size\":25,\"otherBucket\":false,\"otherBucketLabel\":\"Other\",\"missingBucket\":false,\"missingBucketLabel\":\"Missing\",\"customLabel\":\"service\"},\"schema\":\"bucket\"}],\"params\":{\"perPage\":10,\"showPartialRows\":false,\"showMetricsAtAllLevels\":false,\"showTotal\":false,\"totalFunc\":\"sum\",\"percentageCol\":\"\"}}"},"id":"cd23dc20-2f60-11ef-9514-4fea472f4f07","migrationVersion":{"visualization":"7.10.0"},"references":[{"id":"12a67740-2f60-11ef-9514-4fea472f4f07","name":"kibanaSavedObjectMeta.searchSourceJSON.index","type":"index-pattern"}],"type":"visualization","updated_at":"2024-06-20T23:57:07.682Z","version":"WzU1LDFd"}
              {"attributes":{"description":"count services events","kibanaSavedObjectMeta":{"searchSourceJSON":"{\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filter\":[],\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}"},"title":"ingest-services-events-count","uiStateJSON":"{}","version":1,"visState":"{\"title\":\"ingest-services-events-count\",\"type\":\"table\",\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"params\":{\"customLabel\":\"count\"},\"schema\":\"metric\"},{\"id\":\"2\",\"enabled\":true,\"type\":\"terms\",\"params\":{\"field\":\"serviceName.keyword\",\"orderBy\":\"1\",\"order\":\"desc\",\"size\":25,\"otherBucket\":false,\"otherBucketLabel\":\"Other\",\"missingBucket\":false,\"missingBucketLabel\":\"Missing\",\"customLabel\":\"service\"},\"schema\":\"bucket\"}],\"params\":{\"perPage\":10,\"showPartialRows\":false,\"showMetricsAtAllLevels\":false,\"showTotal\":false,\"totalFunc\":\"sum\",\"percentageCol\":\"\"}}"},"id":"a7d3d1a0-14f3-11ef-8c27-a723ded8020e","migrationVersion":{"visualization":"7.10.0"},"references":[{"id":"2ba34950-14f1-11ef-8c27-a723ded8020e","name":"kibanaSavedObjectMeta.searchSourceJSON.index","type":"index-pattern"}],"type":"visualization","updated_at":"2024-06-20T23:17:22.417Z","version":"WzE4LDFd"}
              ....

Additional context

# import  a saved objects 
curl \
    -snk \
    --netrc-file ~/.netrc \
    -H "Content-Type: application/json" \
    -H "osd-xsrf:true" \
    -XPOST \
    https://my.opensearch-dashboards.url/api/saved_objects/_import \
    -d '{"type":["index-pattern","config","search","dashboard","url","query","visualization"],"includeReferencesDeep":true}'