# Host Case Sensitive

**URL:** <https://community.influxdata.com/t/host-case-sensitive/19992>\
**Category:** InfluxDB 2\
**Created:** [May 20, 2021, 11:24am UTC](https://community.influxdata.com/t/host-case-sensitive/19992 "2021-05-20T11:24:36Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![ThePeltonian](https://avatars.discourse-cdn.com/v4/letter/t/a3d4f5/32.png) [@ThePeltonian](https://community.influxdata.com/u/ThePeltonian)\
**Post date:** [May 20, 2021, 11:24am UTC](https://community.influxdata.com/t/host-case-sensitive/19992/1 "2021-05-20T11:24:36Z")

</div>

Hello,

I have setup Grafana Dashboard that pulls hosts from InfluxDBV2 with a custom list of windows hosts within the variables, my problem is that the HOSTS can be either uppercase or lowercase so when setting the variable I have to put in both Upper and Lowercase versions - this is a bit messy as on the dropdown it shows both and 1 does not work, how can i get around this?

The custom list is

server1,server2,server3 etc

I cant see where i can change this to be case insensitive

piped query for data

from(bucket: “bucket”)  
|\> range(start: v.timeRangeStart, stop: v.timeRangeStop)  
|\> filter(fn: (r) =\> r["\_measurement"] == “sql\_cpu”)  
|\> filter(fn: (r) =\> r[“host”] =~ /${comp:pipe}/)  
|\> filter(fn: (r) =\> r["\_field"] == “Percent\_Processor\_Time” or r["\_field"] == “Percent\_User\_Time” or r["\_field"] == “Percent\_Privileged\_Time”)  
|\> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)  
|\> yield(name: “mean”)

Has anyone got any ideas to get around this issue?

---

<div class="post-metadata">

**Author:** ![philb](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/philb/32/1805_2.png) [@philb](https://community.influxdata.com/u/philb)\
**Post date:** [May 20, 2021, 1:10pm UTC](https://community.influxdata.com/t/host-case-sensitive/19992/2 "2021-05-20T13:10:44Z")

</div>

I’m not familiar with InfluxDB 2.0 however if I was to do this with Telegraf and InfluxDB 1.x then I’d use the string processor for Telegraf.

[Strings](https://github.com/influxdata/telegraf/tree/master/plugins/processors/strings)

We have pretty much same use case regarding the naming. A lot of the systems we monitor have been confiigured by other people who have used different naming conventions throughout.

We force all tags in to uppercase to be honest to make it easier to manage.

---

<div class="post-metadata">

**Author:** ![scott](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/scott/32/16492_2.png) [@scott](https://community.influxdata.com/u/scott)\
**Post date:** [May 20, 2021, 2:55pm UTC](https://community.influxdata.com/t/host-case-sensitive/19992/3 "2021-05-20T14:55:52Z")

</div>

@ThePeltonian You can just force the correct case in your query using the `strings` package. This is a lot easier if the correct case is lower. You’ll also need to use the `regexp` to convert the forced-lowercase host value into a usable regexp type:

```javascript
import "strings"
import "regexp"

hostValue = strings.toLower(v: "${comp:pipe}")
hostRegex = regexp.compile(v: hostValue)

from(bucket: "bucket")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "sql_cpu")
  |> filter(fn: (r) => r["host"] =~ hostRegex)
  |> filter(fn: (r) => r["_field"] == "Percent_Processor_Time" or r["_field"] == "Percent_User_Time" or r["_field"] == "Percent_Privileged_Time")
  |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
  |> yield(name: "mean")

```

---

<div class="post-metadata">

**Author:** ![ThePeltonian](https://avatars.discourse-cdn.com/v4/letter/t/a3d4f5/32.png) [@ThePeltonian](https://community.influxdata.com/u/ThePeltonian)\
**Post date:** [May 20, 2021, 3:48pm UTC](https://community.influxdata.com/t/host-case-sensitive/19992/4 "2021-05-20T15:48:18Z")

</div>

Hi Scott thanks for that, when implement the above it does not work - on the selection I choose an uppercase host nothing comes back but when changing the hostValue = strings.toLower(v: “${comp:pipe}”) to hostValue = strings.toUpper(v: “${comp:pipe}”) it pulls back the uppercase selected host metrics

I think the issue is that the “Hosts” are in InfluxDB as mixed case some lower some upper so unable to predict which.

import “influxdata/influxdb/schema”  
schema.tagValues(bucket: “mssql”, tag: “host”)

This is one of the queries to pull back host tags - this is used on certain dashboards

But mainly I use similar to the one posted - @philb do you have an example?

Would it be such as

## Convert a tag value to uppercase

[[processors.strings.uppercase]]  
tag = “host”

---

<div class="post-metadata">

**Author:** ![ThePeltonian](https://avatars.discourse-cdn.com/v4/letter/t/a3d4f5/32.png) [@ThePeltonian](https://community.influxdata.com/u/ThePeltonian)\
**Post date:** [May 20, 2021, 4:11pm UTC](https://community.influxdata.com/t/host-case-sensitive/19992/5 "2021-05-20T16:11:19Z")

</div>

Have just tried the above within the telegraf.conf - failed start, I tried within the Global / Agent tags and within the outputs and inputs sections all failed to start.

---

<div class="post-metadata">

**Author:** ![scott](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/scott/32/16492_2.png) [@scott](https://community.influxdata.com/u/scott)\
**Post date:** [May 20, 2021, 8:22pm UTC](https://community.influxdata.com/t/host-case-sensitive/19992/6 "2021-05-20T20:22:16Z")

</div>

I’m not sure about the Telegraf issue, but in the Flux filter, you can force lower case on both operands of the predicate expression:

```javascript
// ...
  |> filter(fn: (r) => strings.toLower(v: r["host"]) =~ hostRegex)

```

---

<div class="post-metadata">

**Author:** ![scott](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/scott/32/16492_2.png) [@scott](https://community.influxdata.com/u/scott)\
**Post date:** [May 20, 2021, 10:14pm UTC](https://community.influxdata.com/t/host-case-sensitive/19992/7 "2021-05-20T22:14:49Z")

</div>

@ThePeltonian I just learned something new in Flux today. You can add flags to a regular expression to make it case-insensitive. The only catch is that you can only do it if you’re using the `regexp` package (for now at least).

Try this:

```javascript
import "strings"
import "regexp"

hostRegex = regexp.compile(v: "($i)${comp:pipe}")

from(bucket: "bucket")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "sql_cpu")
  |> filter(fn: (r) => r["host"] =~ hostRegex)
  |> filter(fn: (r) => r["_field"] == "Percent_Processor_Time" or r["_field"] == "Percent_User_Time" or r["_field"] == "Percent_Privileged_Time")
  |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
  |> yield(name: "mean")

```

---

<div class="post-metadata">

**Author:** ![ThePeltonian](https://avatars.discourse-cdn.com/v4/letter/t/a3d4f5/32.png) [@ThePeltonian](https://community.influxdata.com/u/ThePeltonian)\
**Post date:** [May 21, 2021, 9:52am UTC](https://community.influxdata.com/t/host-case-sensitive/19992/8 "2021-05-21T09:52:04Z")

</div>

Hi @scott, sadly cant seem to get that to work within Grafana ☹ 😓

I think i am in need of sorting this out within the InfluxDB itself to sort this out sadly.

I have a few issues with the SQLServer side of things about settings etc but the above is a main one;

---

<div class="post-metadata">

**Author:** ![philb](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/philb/32/1805_2.png) [@philb](https://community.influxdata.com/u/philb)\
**Post date:** [May 21, 2021, 10:41am UTC](https://community.influxdata.com/t/host-case-sensitive/19992/9 "2021-05-21T10:41:36Z")

</div>

Thats close, but it should be

```
[[processors.strings]]
  ## Convert a tag value to uppercase
   [[processors.strings.uppercase]]
     tag = "host"

```

Also, I’m not sure if its the formatting on the forums or not but the double quotes don’t seem right.

```
[[processors.strings.uppercase]]
tag = “host”

```

try with “host” instead.

I place that at the very end of my main configuration file with all the connection details in and its applied to all my metrics, however I force all tags to uppercase so i just use the wildcard

```
[[processors.strings]]
  ## Convert a tag value to uppercase
   [[processors.strings.uppercase]]
     tag = "*"

```

As for Grafana, maybe that regex function works in influx but not Grafana. I don’t know about influx 2.0 though so its just a vage guess.

EDIT: Actually, i think you might have included that full processor block. I just saved this post and the first section of the definition is formatted in bold text.

It might be better to wrap config snippets in the code formatting

 ![image](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/b/b562ea382b4add1990d819f5b00815c9b90e473b.png)

---

<div class="post-metadata">

**Author:** ![ThePeltonian](https://avatars.discourse-cdn.com/v4/letter/t/a3d4f5/32.png) [@ThePeltonian](https://community.influxdata.com/u/ThePeltonian)\
**Post date:** [May 21, 2021, 10:59am UTC](https://community.influxdata.com/t/host-case-sensitive/19992/10 "2021-05-21T10:59:08Z")

</div>

> [@philb](#):
>
> ```auto
> [[processors.strings]]
> ## Convert a tag value to uppercase
> [[processors.strings.uppercase]]
> tag = "*"
> 
> ```

Perfect!!!

used that at the end then its started to add them in as uppercase - thankyou so much

Just need to sort the sql inputs now 🙂

---

<div class="post-metadata">

**Author:** ![philb](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/philb/32/1805_2.png) [@philb](https://community.influxdata.com/u/philb)\
**Post date:** [May 21, 2021, 1:56pm UTC](https://community.influxdata.com/t/host-case-sensitive/19992/11 "2021-05-21T13:56:31Z")

</div>

Awesome, glad its sorted 🙂

Regarding SQL inputs, are you collecting performance data from SQL server or are you wanting to query a SQL source and write it to Infux?

---

<div class="post-metadata">

**Author:** ![ThePeltonian](https://avatars.discourse-cdn.com/v4/letter/t/a3d4f5/32.png) [@ThePeltonian](https://community.influxdata.com/u/ThePeltonian)\
**Post date:** [May 21, 2021, 2:00pm UTC](https://community.influxdata.com/t/host-case-sensitive/19992/12 "2021-05-21T14:00:49Z")

</div>

collecting from sql server,

I have a couple of servers that have old sql 2005 database’ that have been upgraded to 2012 (i think its 2012) but telegraf starts but then stops when it gets to collecting that data.

I can add in the base configuration but not the Inputs.sql

I was wondering about using the database\_type = sql\_server but cant find any examples of telegraf configs with it in.

---

<div class="post-metadata">

**Author:** ![philb](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/philb/32/1805_2.png) [@philb](https://community.influxdata.com/u/philb)\
**Post date:** [May 25, 2021, 12:45pm UTC](https://community.influxdata.com/t/host-case-sensitive/19992/13 "2021-05-25T12:45:53Z")

</div>

Sorry for the delay.

It should be simple enough to set up. does telegraf output any errors when connecting?

If i recall, you just need to create a user with the correct permissions and set up the connection string in the config. I can’t remember if I had to make any firewall changes or network settings in the SQL server instance itself.

---

<div class="post-metadata">

**Author:** ![ThePeltonian](https://avatars.discourse-cdn.com/v4/letter/t/a3d4f5/32.png) [@ThePeltonian](https://community.influxdata.com/u/ThePeltonian)\
**Post date:** [June 1, 2021, 7:35am UTC](https://community.influxdata.com/t/host-case-sensitive/19992/14 "2021-06-01T07:35:54Z")

</div>

Hi @philb sorry been away from work, no errors the config is the same as the ones on the other servers - firewall is open etc as I can add in the basic Telegraf config without the SQL additions and it worked.

I have read that Telegraf has issues with older versions of SQL so was wondering if the upgraded db;s had some remnants left in there somewhere that causes Telegraf to stop
