user6845507
user6845507

Reputation:

InfluxDB cannot select field key

I'm new to InfluxDB. I have an existing database with a table language. When I run select * from language I get the following table:

name: language
time                     application_guid application_name application_type instance_index lang metric_type stream_name value
----                     ---------------- ---------------- ---------------- -------------- ---- ----------- ----------- -----
2019-03-07T07:46:49.225Z 31429            counter          sink             0              ar   counter     tweetlang   0
2019-03-07T07:46:49.225Z 31429            counter          sink             0              ca   counter     tweetlang   0
2019-03-07T07:46:49.225Z 31429            counter          sink             0              de   counter     tweetlang   0
2019-03-07T07:46:49.225Z 31429            counter          sink             0              el   counter     tweetlang   0

When I run select "lang" from language I get an empty result. What is the problem here?

Upvotes: 2

Views: 1513

Answers (2)

Sabuhi Shukurov
Sabuhi Shukurov

Reputation: 1916

According to documentation Select Clause can be given to field key and possible to give query with field name and tag key together where tag key is for indexing and field is what you defined as a column in the measurement.

If a select query will be given by a tag name, it won't return any result.

According to your measurement named language has lang key as a tag key.

if we consider your field names as follows:

application_guid application_name application_type instance_index

And tags as given below:

lang metric_type stream_name value

The select query can be given like these ways:

select * from language

select application_guid,lang from language

if multiple field and tags you want to give in the statement then:

select application_guid,application_type::field, metric_type,stream_name::tag from language

In addition, InfluxDb uses Line protocol, where line protocol informs InfluxDB of the data’s measurement, tag set, field set, and timestamp.

Upvotes: 0

user6845507
user6845507

Reputation:

Found the solution here:

The SELECT clause must specify at least one field when it includes a tag.

Upvotes: 1

Related Questions