SQL Column Name Appears in Panel

  • What Grafana version and what operating system are you using?

  • What are you trying to achieve?
    Building a horizontal bar gauge visualization of application names and dollar cost per application.

  • How are you trying to achieve it?
    Retrieving data from MySQL database and using the time series transformation.

My SQL is:

select cost_date, application_name, cost from grafana_data.monthly_cost
where ‘$costdate’ = date_format(cost_date, ‘%m/%d/%y’)
order by cost desc
limit 15;

So I’m looking for the top 15 application costs. As this is a monthly calculation I use a dashboard variable (costdate) to allow the user to select which month they’re interested in. Everything works as it should EXCEPT the application names appear as:

cost VAM - Profile and Server |||||| $184K

The word “cost” should not be there, it a a column name in the table where the 184k is stored.

I tried to regex out “cost” but I’m not very good with regex, but I shouldn’t have to do that. I’m retrieving 3 columns, data, application and cost. The VALUE stored in the cost column in my table should show up in the last column - and it does - but I don’t know why the application name is being prefixed by a column name.

I’m sure I’m doing something goofy but I can’t see it.

Thanks,

Greg

  • What happened?
    I do get an horizontal bar gauge but the application name is prefixed with “cost” which is one of the columns in my MySQL table. This works fine when using a CSV as input.

  • What did you expect to happen?
    I expected a two column gauge - application name and cost.

  • Can you copy/paste the configuration(s) that you are having problems with?

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
    No

  • Did you follow any online instructions? If so, what is the URL?
    No.

Column names should be [time], metric and value as show here.

Hi and thanks for the input. As usual, the more you pick at it, the worse it gets!

cost_date is critical as I have month’s worth of data and I’m using cost_date as a dashboard variable to allow the user to select what month they’re interested in. So I select directly for that month which is a date without a time stamp.

Looking at your SQL, I’m having a hard time understanding why selecting columns as different names would make a difference on what gets displayed in the visualization. I admit to being a complete newbie to both MySQL and Grafana so I’m sure there’s a reason that I just don’t know.

Thanks,

Greg

Because that is how grafana needs them