I have two template variables and I want that after selecting first template variable from dropdown, second template variable should be dynamic based on first variable value.
let me clear this scenario with an example:
assume I have this data:
data=> System=10
tags=> appName="a", appVersion="1.1"
data=> System=12
tags=> appName="b", appVersion="2.1"
I have defined two template variables :appName: and :appVersion:
and Im getting their values using this meta query
SHOW TAG VALUES ON "db_name" FROM "measurement_name" WITH KEY = appName
SHOW TAG VALUES ON "db_name" FROM "measurement_name" WITH KEY = appVersion
now whenever I select :appName: = 'a', I want that :appVersion: should show only "1.1" value in dropdown. But :appVersion: shows both values "1.1" and "2.1". We know "2.1" value is useless when we have selected appName=a.
I thought I can use this for defining :appVersion:
SHOW TAG VALUES ON "db_name" FROM "measurement_name" WITH KEY = appVersion WHERE appName = :appName:
but this is not working
Please help me to achieve this kind of dynamic/codependent variables in chronograf
solved this with this:
show tag values on "db_name" from "measurement_name" with key = "appVersion" where appName = ':app_name:'
I had to use single quote after where clause. Seems I cant use " here
Related
I am testing some network packets of my Organisation's product. We already have custom plugins. I am trying to add some some more fields into those existing plugins (like conversion of 2 byte code to a string and assign it to a field)
Thankyou in advance for reading my query.
--edit
Wireshark version : 2.4.5 (organization's plugins dont work on latest wireshark application)
--edit
Problem statement:
I am able to add field and show value, but fieldname is not displayed as defined.
I cannot share the entire .lua file but i will try to explain What i did:
Below is the image where I have a field aprint.type. this is a two byte field. In .lua file, for display purpose it is appended with corresponding description using a custom function int_to_enum.
I want to add one more proto field aprint.typetext which will show the text.
What I did:
Added a protofield f_apr_msg_type_txt = ProtoField.string("aprint.typetxt","aprint_type_text") (Tried f_apr_msg_type_txt = ProtoField.string("aprint.typetxt","aprint_type_text",FT_STRING) also)
Below the code where subtree aprint.type is shown, added my required field as subtree:add(f_apr_msg_type_txt, msg_type_string) (Below is image of code extract)
I am able to see the text but field Name is shown as Wireshark Lua text (_ws.lua.text)
Normally displaying strings based on numeric values is accomplished by a value string lookup, so you'd have something like so:
local aprint_type_vals = {
[1] = "Foo",
[2] = "Bar",
[9] = "State alarm"
}
f_apr_msg_type = ProtoField.uint16("aprint.type", "Type", base.DEC, aprint_type_vals)
f_apr_msg_type_txt = ProtoField.string("aprint.typetxt","aprint_type_text", base.ASCII)
... then
local msg_type = tvb(offset, 2):le_uint()
subtree:add_le(f_apr_msg_type, tvb(offset, 2))
subtree:add(f_apr_msg_type_txt, tvb(offset, 2), (aprint_type_vals[msg_type] or "Unknown"))
--[[
Alternatively:
subtree:add(f_apr_msg_type_txt, tvb(offset, 2)):set_text("aprint_type_text: " .. (aprint_type_vals[msg_type] or "Unknown"))
--]]
I'm also not sure why you need the extra field with only the text when the text is already displayed with the existing field, but that's basically how you'd do it.
I have points from my Input like these two:
http,Location=Foo Key="Humidity",Value=68 1659704523000000000
http,Location=Foo Key="Temperature",Value=24,1 1659704523000000000
But I have to store them like these:
http,Location=Foo Humidity=68 1659704523000000000
http,Location=Foo Temperature=24,1 1659704523000000000
I saw almost all of Processor plugin docs, but I still not sure it is possible to use field value as a field name. Isn't it?
I still not sure it is possible to use field value as a field name. Isn't it?
Yep! The starlark processor will do this. The 'pivot' example is what you are after.
The following will create a new field based on the values of Key and Value and then remove the original values:
[[processors.starlark]]
source = '''
def apply(metric):
metric.fields[str(metric.fields['Key'])] = metric.fields['Value']
metric.fields.pop('Key',None)
metric.fields.pop('Value',None)
return metric
'''
I am using Telegraf with Telemetry, I want to see traffic level on interface based on their description, "/interfaces/interface/subinterfaces/subinterface/state/description". Unfortunately the interface description was as field key, which I converted using the processors.converter. Since I needed to rewrite the data after this, I just dropped the whole measurement so the new tag can take place.
I do see the descriptions as tag fields and I do see the interface description as a tag key.
Unfortunately I am still getting blank results on any query when I try with querying by interface description.
### Relevant telegraf.conf:
# Convert values to another metric value type
[[processors.converter]]
# Fields to convert
[processors.converter.fields]
tag = ["/interfaces/interface/subinterfaces/subinterface/state/description"]
System info:
Telegraf 1.14.5
Debian
Steps to reproduce:
> select "/interfaces/interface/subinterfaces/subinterface/state/description" from "/interfaces/"
(empty result) this is expected since now its a tag
> show tag keys
name: /interfaces/
tagKey
------
/interfaces/interface/subinterfaces/subinterface/state/description
we can see here that now it's as a tag key
> show tag values with key = "/interfaces/interface/subinterfaces/subinterface/state/description"
(gives all descriptions)
> SELECT "/interfaces/interface/subinterfaces/subinterface/state/counters/out-pkts" from /interfaces/ where "/interfaces/interface/subinterfaces/subinterface/state/description" = 'some_description'
(empty result) Where I would like to have some result based on the interface description
Expected behavior:
SELECT "/interfaces/interface/subinterfaces/subinterface/state/counters/out-pkts" from /interfaces/ where "/interfaces/interface/subinterfaces/subinterface/state/description" = 'some_description'
to give some a result for the interface with that description
Actual behavior:
SELECT "/interfaces/interface/subinterfaces/subinterface/state/counters/out-pkts" from /interfaces/ where "/interfaces/interface/subinterfaces/subinterface/state/description" = 'some_description'
(is not returning any result)
Additional information
I am also using Chronograph which gives no results too.
You cannot just select just a tag from a measurement. For influx to return results it needs atleast one field in the select clause.
step1 - Declared "appname" as choice parameter with 10 values.(single select)
step2 - To get the latest artifact of the above appname, used "artifact_name" as extended choice param
with 'max count-10' delimeter as ','
So the "artifact_name" values , i mean the last artifacts like 10 should be displayed inside
"single select" list box of "artifact_name"
-> Groovy Source script for "artifact_name" value is below.
def filter= "${params.appname}" //Not able to get above declared variable to new variable and use it dynamically in below url to filter the artifacts)
def con = def connection = new URL( "https://hostname/artifactory/source-artifactory/$filter/?list&deep=1&listFolders=0&mdTimestamps=1&includeRootPath=0" )
.openConnection() as HttpURLConnection
So am not able to access the "appname" value and assign it to a new variable like "def filter = "${params.appname}" and use the new variable in connection url for every application name to get the artifacts. S
Hardcoded value working but i have 10 apps can't create ten jobs with hardcoded values.
I'm trying to make templates for my dahboards, and I have problems when it comes to referring to measuerment names.
My variables:
$space = SHOW MEASUREMENTS
Then I would like a variable that contains only values from a specific $space, which is actually a MEASUREMENT:
$app = SHOW TAG VALUES WITH KEY = "Application" WHERE MEASUREMENT =~ /^$space$/
Here I get a message: Template variables could not be initialized: error parsing query: found MEASUREMENT, expected identifier, string, number, bool at line 1, char 48
In the official example it is like this, though it refers to another tag:
$datacenter = SHOW TAG VALUES WITH KEY = "datacenter"
$host = SHOW TAG VALUES WITH KEY = "hostname" WHERE "datacenter" =~ /^$datacenter$/
I cannot find any info how to refer to MEASUREMENTS which would work. WHERE, WITH, etc.. Maybe is it not possible at all?
I found only this in the official tutorial, but this is for keys, not values.
SHOW TAG KEYS [FROM <measurement_name>]
I actually figured it out:
SHOW TAG VALUES FROM /^$space$/ WITH KEY = "Application"