Apache Nifi append function - apache-nifi

$.id:append('-') & ${id:append('-')} in Evaluate JsonPathProcessor gives me no results, what would we be the correct way to append a text at the end of an incoming attribute in Apache Nifi.

If your Apache NiFi had a sample input JSON document like:
{
"id": "foo"
}
Then you can extract and format attributes in two steps:
EvaluateJsonPath to extract a value from the input JSON document to a NiFi flowfile attribute. For the sample, you might add a custom property json.id with the JsonPath of $.id. A flowfile attribute called json.id will be added to the flowfile with the value foo.
UpdateAttribute to use NiFi Expression Language to format the id. You can assign any attribute, like formatted.id using an expression that references the attribute extracted earlier, json.id:

Related

Is it possible to get dynamic ParameterContext value with Expression Language in NiFi?

How can I get ParameterContext value with dynamic name in Apache NiFi?
For example, for each flowfile I need to get parameter according to ${type} attribute of this flowfile.
Like: #{${type}_parameter}.
Is it possible to do this in NiFi 1.19.1?
I tried ${literal('{${type}_parameter}'):prepend('#'):evaluateELString()}, but it always returns empty string.

Grafana Value Mapping an Array

So I'm using grafana to display some data in a table. So in my grafana table I have a column named 'request_types'. Its value is represented by an array such as
["all"], ["Music", "Film"], ...etc
What I'm trying to do is create value mappings in grafana to map the array to specific values. For example
["all"] -> "All"
["Artist", "Film"] -> Artist, Film
How can I achieve this in grafana? Is value mapping the only option I have?
So in order for me to achieve this I had to create a custom data source plugin. Basically my data source plugin makes an http request to retrieve Elasticsearch data. From there I can write some typescript to manipulate my data.

nifi: How to specify dynamic index name when sending data to elasticsearch

I am new to apache NiFi.
I am trying to put data into elasticsearch using nifi.
I want to specify an index name by combining a specific string and the value converted from a timestamp field into date format.
I was able to create the desired shape with the expression below, but failed to create the index name with the value of the timestamp field of the content.
${now():format('yyyy-MM-dd')}
example json data
{
"timestamp" :1625579799000,
"data1": "abcd",
"date2": 12345
}
I would like to get the following result:
index : "myindex-2021.07.06"
What should I do? please tell me how
I know that if you use the PutElasticSearch Processor, you can provide it with a specific index name to use. And as long as the index name meets the proper ElasticSearch format for naming a new index, if the enable auto index creation in ElasticSearch is turned on, then when sent, Elastic will create the new index with the desired name. This has worked for me. Double check the Elastic Naming Rules that can be found here or https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/es-indexing.html

Apache NiFi. add new CSV field based on existing with modification

I have .csv file with several fields. One of them (for example 3th) contains email. How can I add additional filed that will contain only serverName from email field?
Example:
input:
01;city;name#servername.com;age;
result:
01;city;name#servername.com;age;servername;
I guess it possible through ReplaceText processor, but I can't choose correct value in "Search Value" and "Replacement Value" fields.
You can convert your flowfile, to a record with the help of ConvertRecord.
It allows you to pass to a JSON (or something else) format to whatever you prefer.
Then you can add a new field, like the following, with an UpdateRecordProcessor:
I recommend you the following reading:
Update Record tutorial

Apache NiFi dynamic atributes for PutDatabaseRecord Processor

I have this flow in NiFi:
GetFile -> ConvertExcelToCSVProcessor -> ReplaceText ->
PutDatabaseRecord.
It's working ok but I want to set "table name" property of
PutDatabaseRecord
based on csv file name (and if it's posible to customize it). I can't find anything in docs or web.
Thanks!
According to documentation, the parameter table name of the PutDatabaseRecord processor supports nifi expression language.
So, if the attribute filename of your flow file contains value MyTableName.csv you could use expression with regular expression to convert file name to table name in PutDatabaseRecord processor like this:
Table Name = ${filename:replaceAll('\\..*','')}

Resources