After converting field to tag, no query result - influxdb

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.

Related

thingsboard rulechain - filter script node to check if metadata timestamp is greater than server timestamp

I have created an asset variable with a timestamp attribute (dateTo) and would like to compare this to the current server time.
Ho do I get the server/system time of the Thingsboard. TBEL documentation states that "we have added Date class that you are able to use without the package name" so I should be able to get the server time with:
Date
Testing in the Test Filter Function doesn't error while using:
return Date > metadata.dateTo;
But does not assess correctly (changing the value around generates a False result either way).
Each metadata field has a string type, instead of integer as expected. So before comparison you have to convert metadata.dateTo to integer:
return Date.now() > +metadata.dateTo;

Custom wireshark disector shows value but fieldname is not visible using lua

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.

How to write a SELECT for a field of type "quantity" in SET_GET_ENTITY method?

I want to select a single row with all columns from my table zbookings. zbookings table has a structure based on zbooking data structure - see tables below.
Table ZBOOKINGS:
Structure ZBOOKING:
My BOOKINGSET_GET_ENTITY method:
method BOOKINGSET_GET_ENTITY.
DATA: ls_keytab TYPE LINE OF /IWBEP/T_MGW_NAME_VALUE_PAIR,
i_carrid TYPE string,
i_connid TYPE string,
i_fldate TYPE string,
i_bookid TYPE string.
LOOP AT it_key_tab INTO ls_keytab.
CASE ls_keytab-name.
WHEN 'Carrid'.
i_carrid = ls_keytab-value.
WHEN 'Connid'.
i_connid = ls_keytab-value.
WHEN 'Fldate'.
i_fldate = ls_keytab-value.
WHEN 'Bookid'.
i_bookid = ls_keytab-value.
ENDCASE.
ENDLOOP.
SELECT SINGLE *
INTO CORRESPONDING FIELDS OF er_entity
FROM ybookings AS a
WHERE
a~carrid = i_carrid AND
a~connid = i_connid AND
a~fldate = i_fldate AND
a~bookid = i_bookid.
endmethod.
I tested it via SAP Gateway Client. It's OK when I remove column luggweight from my SELECT SINGLE * statement. However when I select all columns via SELECT SINGLE *, then it outputs an error
Runtime Error: 'SAPSQL_PARSER_TODO_WARNING'`
<?xml version="1.0" encoding="UTF-8"?>
<error>
<code>SAPSQL_PARSER_TODO_WARNING</code>
<message>Runtime Error: 'SAPSQL_PARSER_TODO_WARNING'.
The OData request processing has been abnormal terminated. If "Runtime Error"
is not initial, launch transaction ST22 for details and analysis. Otherwise,
launch transaction SM21 for system log analysis.</message>
<timestamp>20190905144432</timestamp>
</error>
As you can see the problem is with luggweight field which is of quantity type and its typing method is Type ref to. When I check my BOOKINGSET_GET_ENTITY method via ctr+F2 it outputs a warning:
The database field or the result type of the aggregate function LUGGWEIGHT and the component "LUGGWEIGHT" of "ER_ENTITY" are not compatible.
How should I modify my SELECT query / BOOKINGSET_GET_ENTITY method for it to work?
Luggweight field's typing method should be set to Types (not Type ref to) when creating / modifying zbooking data structure.

How to exclude multiple values in OData call?

I am creating a SAPUI5 application. This application is connected to a backend SAP system via OData. In the SAPUI5 application I use a smart chart control. Out of the box the smart chart lets the user create filters for the underlying data. This works fine - except if you try to use multiple 'not equals' for one property. Is there a way to accomplish this?
I found out that all properties within an 'and_expression' (including nested or_expressions) must have unique name.
The reason why two parameters with the same property don't get parsed into the select options:
/IWCOR/CL_ODATA_EXPR_UTILS=>GET_FILTER_SELECT_OPTIONS takes the expression you pass and parses it into a table of select options.
The select option table returned is of type /IWCOR/IF_ODATA_TYPES=>EDM_SELECT_OPTION_T which is a HASHED TABLE .. WITH UNIQUE KEY property.
From: https://archive.sap.com/discussions/thread/3170195
The problem is that you cannot combine NE terms with OR. Because both parameters after the NE should not be shown in the result set.
So at the end the it_filter_select_options is empty and only the iv_filter_string is filled.
Is there a manual way of facing this problem (evaluation of the iv_filter_string) to handle multiple NE terms?
This would be an example request:
XYZ/SmartChartSet?$filter=(Category%20ne%20%27Smartphone%27%20and%20Category%20ne%20%27Notebook%27)%20and%20Purchaser%20eq%20%27CompanyABC%27%20and%20BuyDate%20eq%20datetime%272018-10-12T02%3a00%3a00%27&$inlinecount=allpages
Normally I want this to exclude items with the category 'Notebook' and 'Smartphone' from my result set that I retrieve from the backend.
If there is a bug inside /iwcor/cl_odata_expr_utils=>get_filter_select_options which makes it unable to treat multiple NE filters of the same component, and you cannot wait for an OSS. I would suggest to wrap it inside a new static method that will make the following logic (if you will be stuck with the ABAP implementation i would try to at least partially implement it when i get time):
Get all instances of <COMPONENT> ne '<VALUE>' inside a () (using REGEX).
Replace each <COMPONENT> with <COMPONENT>_<i> so there will be ( <COMPONENT>_1 ne '<VALUE_1>' and <COMPONENT>_2 ne '<VALUE_2>' and... <COMPONENT>_<n> ne '<VALUE_n>' ).
Call /iwcor/cl_odata_expr_utils=>get_filter_select_options with the modified query.
Modify the rt_select_options result by changing COMPONENT_<i> to <COMPONENT> again.
I can't find the source but I recall that multiple "ne" isn't supported. Isn't that the same thing that happens when you do multiple negatives in SE16, some warning is displayed?
I found this extract for Business ByDesign:
Excluding two values using the OR operator (for example: $filter=CACCDOCTYPE ne ‘1000’ or CACCDOCTYPE ne ‘4000’) is not possible.
The workaround I see is to select the Categories you actively want, not the ones you don't in the UI5 app.
I can also confirm that my code snippet I've used a long time for filtering also has the same problem...
* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_MGW_ABS_DATA->FILTERING
* +-------------------------------------------------------------------------------------------------+
* | [--->] IO_TECH_REQUEST_CONTEXT TYPE REF TO /IWBEP/IF_MGW_REQ_ENTITYSET
* | [<-->] CR_ENTITYSET TYPE REF TO DATA
* | [!CX!] /IWBEP/CX_MGW_BUSI_EXCEPTION
* | [!CX!] /IWBEP/CX_MGW_TECH_EXCEPTION
* +--------------------------------------------------------------------------------------</SIGNATURE>
METHOD FILTERING.
FIELD-SYMBOLS <lt_entityset> TYPE STANDARD TABLE.
ASSIGN cr_entityset->* TO <lt_entityset>.
CHECK: cr_entityset IS BOUND,
<lt_entityset> IS ASSIGNED.
DATA(lo_filter) = io_tech_request_context->get_filter( ).
/iwbep/cl_mgw_data_util=>filtering(
exporting it_select_options = lo_filter->get_filter_select_options( )
changing ct_data = <lt_entityset> ).
ENDMETHOD.

InfluxDB templating query - referring to measuerments?

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"

Resources