Splunk Search

How to put comment on the Splunk Dashboard Studio source?

LearningGuy
Builder

Hello,
How to put comment on the Splunk Dashboard Studio source?
The classic Splunk Dashboard I can put comment  on the source using <!--  comment  -->
In the new Splunk Dashboard Studio, I tried to put comment using /* comment */, but I got an error "Comments are not permitted in JSON."
The comment only work on the data configuration query editor

Thank you so much

Labels (1)
0 Karma
1 Solution

yuanliu
SplunkTrust
SplunkTrust

There is no good way to do this.  All you can do is to work around with array, like

{
	"visualizations": {
		"viz_OQMhku6K": {
			"type": "splunk.ellipse",
			"_comment": [
                          "==================================",
                          "This is created by Person1 on 1/1/2023 @companyb",
                          "On 2/1/2023 - added base search",
                          "On 2/5/203  - added dropdown box"
			]
		}
	},

View solution in original post

LearningGuy
Builder

Your solution worked. Thank you so much for your help

0 Karma

yuanliu
SplunkTrust
SplunkTrust

JSON is data-oriented.  Everything is treated as data.  But just like comment is useless and harmless code in "normal" computing languages, you can think of comment as useless and harmless data in JSON.  The trick is to embed useless data in keys that the application does not reject yet does not utilize.  One trick I found from Stackoverflow (there are many like that) is to place an unusual character at the beginning of key but you can design your own pattern as long as DS doesn't find it objectionable and doesn't act on it.  This example uses "_comment":

{
	"visualizations": {
		"viz_OQMhku6K": {
			"type": "splunk.ellipse",
			"_comment": "about vizualization"
		}
	},
	"dataSources": {
		"_comment": [
			"datasource comment 1",
			"source comment 2"
		]
	},
	"defaults": {
		"dataSources": {
			"ds.search": {
				"options": {
					"queryParameters": {
						"latest": "$global_time.latest$",
						"earliest": "$global_time.earliest$"
					}
				}
			}
		}
	},
	"inputs": {
		"input_global_trp": {
			"type": "input.timerange",
			"options": {
				"token": "global_time",
				"defaultValue": "-24h@h,now"
			},
			"title": "Global Time Range"
		}
	},
	"layout": {
		"type": "absolute",
		"_comment": "something about layout",
		"options": {
			"display": "auto-scale",
			"backgroundImage": {
				"sizeType": "contain",
				"x": 0,
				"y": 0,
				"src": "splunk-enterprise-kvstore://649ab2cf9e8252528a4843f1"
			}
		},
		"structure": [
			{
				"item": "viz_OQMhku6K",
				"type": "block",
				"position": {
					"x": 130,
					"y": 60,
					"w": 130,
					"h": 130
				},
				"_commment": "structure comment here"
			}
		],
		"globalInputs": [
			"input_global_trp"
		]
	},
	"_comment": "general comments go here",
	"description": "",
	"title": "Test Dashboard Studio comment"
}

Hope this helps.

LearningGuy
Builder

@yuanliu 

Your suggestion worked for me, but is there a way to put comments with Carriage Return in multiple lines?
See below.. Thanks

{
	"visualizations": {
		"viz_OQMhku6K": {
			"type": "splunk.ellipse",
			"_comment": "
                            ==================================
                           This is created by Person1 on 1/1/2023 @companyb
                           On 2/1/2023 - added base search  
                           On 2/5/203  - added dropdown box
                         "
		}
	},

 

0 Karma

yuanliu
SplunkTrust
SplunkTrust

There is no good way to do this.  All you can do is to work around with array, like

{
	"visualizations": {
		"viz_OQMhku6K": {
			"type": "splunk.ellipse",
			"_comment": [
                          "==================================",
                          "This is created by Person1 on 1/1/2023 @companyb",
                          "On 2/1/2023 - added base search",
                          "On 2/5/203  - added dropdown box"
			]
		}
	},
Get Updates on the Splunk Community!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...