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!

Stay Connected: Your Guide to November Tech Talks, Office Hours, and Webinars!

&#x1f342; Fall into November with a fresh lineup of Community Office Hours, Tech Talks, and Webinars we’ve ...

Transform your security operations with Splunk Enterprise Security

Hi Splunk Community, Splunk Platform has set a great foundation for your security operations. With the ...

Splunk Admins and App Developers | Earn a $35 gift card!

Splunk, in collaboration with ESG (Enterprise Strategy Group) by TechTarget, is excited to announce a ...