DevOps: Working with Parameter Contexts in Apache NiFi 1.11.4+

Timothy Spann. 🇺🇦 - Sep 23 '20 - - Dev Community

DevOps: Working with Parameter Contexts in Apache NiFi 1.11.4+

nifi list-param-contexts -u http://localhost:8080 -ot simple

Id Name Description


1 3a801ff4-1f73-1836-b59c-b9fbc79ab030 backupregistry

2 7184b9f4-0171-1000-4627-967e118f3037 health

3 3a801faf-1f87-1836-54ba-3d913fa223ad retail

4 3a801fde-1f73-1836-957b-a9f4d2c9b73d sensors

> nifi export-param-context -u http://localhost:8080 -verbose --paramContextId 3a801faf-1f87-1836-54ba-3d913fa223ad

{

"name" : "retail",

"description" : "",

"parameters" : [ {

"parameter" : {

  "name" : "allquery",

  "description" : "",

  "sensitive" : false,

  "value" : "SELECT \* FROM FLOWFILE"

}
Enter fullscreen mode Exit fullscreen mode

}, {

"parameter" : {

  "name" : "allrecordssql",

  "description" : "",

  "sensitive" : false,

  "value" : "SELECT \* FROM FLOWFILE"

}
Enter fullscreen mode Exit fullscreen mode

}, {

"parameter" : {

  "name" : "energytopic",

  "description" : "",

  "sensitive" : false,

  "value" : "energy"

}
Enter fullscreen mode Exit fullscreen mode

}, {

"parameter" : {

  "name" : "importantsql",

  "description" : "",

  "sensitive" : false,

  "value" : "SELECT \* FROM FLOWFILE\nWHERE kernel\_logs like '%SIGKILL%'"

}
Enter fullscreen mode Exit fullscreen mode

}, {

"parameter" : {

  "name" : "itempricetable",

  "description" : "",

  "sensitive" : false,

  "value" : "impala::default.itemprice"

}
Enter fullscreen mode Exit fullscreen mode

}, {

"parameter" : {

  "name" : "itsgettingHotInHere",

  "description" : "",

  "sensitive" : false,

  "value" : "SELECT \* FROM\nFLOWFILE\nWHERE CAST (temp\_f as DOUBLE) > 80\nAND UPPER(location) LIKE '%NJ%'"

}
Enter fullscreen mode Exit fullscreen mode

},

You can now move that to another server and import. nifi import-param-context.

bin/cli.sh nifi list-param-contexts -u http://localhost:8080 -ot json

Use simple for a simple table list.

bin/cli.sh nifi export-param-context -u http://localhost:8080 --paramContextId 3a801ff4-1f73-1836-b59c-b9fbc79ab030 -ot json -o backupregistry.json

Example Shell Script

/Users/tspann/Downloads/nifi-toolkit-1.12.0/bin/cli.sh nifi export-param-context -u http://localhost:8080 --paramContextId a13e3764-134c-16f0-7c35-312b7ee4b182 -ot json -o financial.json

/Users/tspann/Downloads/nifi-toolkit-1.12.0/bin/cli.sh nifi export-param-context -u http://localhost:8080 --paramContextId 7184b9f4-0171-1000-4627-967e118f3037 -ot json -o health.json

/Users/tspann/Downloads/nifi-toolkit-1.12.0/bin/cli.sh nifi export-param-context -u http://localhost:8080 --paramContextId 3a801faf-1f87-1836-54ba-3d913fa223ad -ot json -o retail.json

/Users/tspann/Downloads/nifi-toolkit-1.12.0/bin/cli.sh nifi export-param-context -u http://localhost:8080 --paramContextId 3a801fde-1f73-1836-957b-a9f4d2c9b73d -ot json -o sensors.json

/Users/tspann/Downloads/nifi-toolkit-1.12.0/bin/cli.sh nifi export-param-context -u http://localhost:8080 --paramContextId 3a801ff4-1f73-1836-b59c-b9fbc79ab030 -ot json -o backupregistry.json

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .