list of csv headers as values / variables #1208
-
Hi, I'm trying to get column name on CSV to create variable on the dashboard but I tried couple solution its did not work as. I expected. | limit 1 I thought it should return columns header, but instead return list of value on the first row. Could you provide more insight how to get column header name please. Best, |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 9 replies
-
What does your CSV looks like and what column your are expecting see as variable? Also the uql you tried... |
Beta Was this translation helpful? Give feedback.
-
right.. found a hack https://play.grafana.org/goto/KvJSQjoNR?orgId=1. Idea is to pretend the csv doesn't have headers and injecting a header. By using fake delimiter, entire first line will become single field. For reference the UQL query is parse-csv --delimiter ";;;" --columns 'headers' ## prepending fake headers using dummy delimiter
| limit 1 ## limit it to first row which contain headers
| project "header"=split("headers",',') ## split the csv values into array
| mv-expand "server"="header" ## expand array item into rows
| where "server" != 'metric' ## removing unnecessary headers if required
# | echo "foo" ## You can comment out line by prepending # to debug ![]() and as a variable ![]() |
Beta Was this translation helpful? Give feedback.
-
@yesoreyeram this is absolute wonderful, I really appreciate it let me try it out. |
Beta Was this translation helpful? Give feedback.
right.. found a hack https://play.grafana.org/goto/KvJSQjoNR?orgId=1. Idea is to pretend the csv doesn't have headers and injecting a header. By using fake delimiter, entire first line will become single field.
For reference the UQL query is