Is there a way to search curly braces in kibana? - elasticsearch

How can I search for empty curly braces in kibana ?
e.g.
I have some messages in elasticsearch:
test1 1235512 {"command":"session","params":{}} test1
test2 1235512 {"command":"session","params":{"k1": "p1"}} test2
test3 1235512 {"command":"session","params":{"k2": "p2"}} test3 df
test4 1235512 {"command":"session","params":{}} test4 some more text
I need to find all documents where exists empty curly braces {}. For this case in response I want to get test1 and test4 documents. Or if someone can give the elasticsearch request it also can be very helpful )

If you just wanna search on kibana, why not simply try this?
works for me.

Related

Eliminate Unwanted Characters in Ansible print

I store information in a varible HOST in ansible via register command. Then I am trying to print the contents(INFORMATION-1 to 3) of variable HOST line after line.
INFORMATION-1
INFORMATION-2
INFORMATION-3
Instead I am getting this result when printed.
[[u'INFORMATION-1'], [u'INFORMATION-2'], [u'INFORMATION-3']]
Any ideas how I eliminate those unwanted characters like brackets [ ], u and apostrophe(') and print the result in my desired format?
Any ideas how I eliminate those unwanted characters like brackets [ ], u and apostrophe(') and print the result in my desired format?
It's because whatever thing you are printing is actually a python list containing 3 python lists which themselves contain a unicode str
If you want them to be line delimited, then the join() filter will do that for you, and it should be safe to use a join for the inner lists, too, in case you ever end up with more than one value in the inner list:
# assuming your values are in a variable named "list_list_str"
- debug: var=the_output
vars:
the_output: '{{ list_list_str | map("join", "\n") | join("\n") }}'

How can I escape single quotes for Ansible/Jinja2 ternary operator?

I have the snippet below. Basically, for an included task I would like to provide a variable whose contents look like the below string:
--date='something'
or it should be empty if the original variable is an empty string. The thing is, I need the string to be in the form above, including the single quotes around the value.
If I wouldn't need the single quotes, everything works perfectly! However, as I need them, I am trying to escape them using the below snippet. Unfortunately, what I have doesn't seem to work, as \' doesn't apply as expected. How can I properly escape ' so that get them in my string?
tasks:
- include_tasks: ../tasks/get_current.yml
- include_tasks: ../tasks/failed_jobs_stats.yml
vars:
date_param: "{{ date_start != '' | ternary('--date=\''+date_start+'\'', '') }}"
This is not a quoting problem, this is an operator precedence problem.
In your example, you:
apply the ternary filter to the empty string ''
compare the above result to date_start
What you need to do is to enclose the condition in parens:
date_param: "{{ (date_start != '') | ternary('--date=\''+date_start+'\'', '') }}"

I cannot understand this grep pattern

file="value"
here is the content of value:
first col1 col2 col3
second col1 col2 col3
three col1 col2 col3
wanted output:
first col1 col2 col3
three col1 col2 col3
condition: we work with variables not with files directly. the search pattern should be stored in a variable as well.
In order to have this result, I do:
var=second
grep -v $var $file > $tmp;mv $tmp $file
tmp must be initialized with any value in order to work
But I came accross this and I just do not understand my bash anymore:
grep −v "^${var}," $file > $tmp;mv $temp $file
Apart from the fact that it does not work for me, I would like to understand the meaning or at least what it is intended to do; maybe I can arrange it after.
what does mean "^${var}," !!??
what I know so far:
^ -> start of line
$ -> end of line
^$ -> ?
{} -> match exactly
, -> ?
all these symbols together -> ?
Any idea folks ? thank you so much.
Your command is using double quotes, which means that bash gets to play with the argument first.
In the following:
grep −v "^${var}," $file > $tmp;mv $temp $file
...with:
var=foo
...bash will expand ${var} to foo, resulting in:
grep −v "^foo," $file > $tmp;mv $temp $file
(it'll also expand $file, $tmp and $temp (?), but that's not interesting)
To add to Roger's answer,
defining your variable between {} within a string indicate to bash which part is the string and which part is the variable.
For instance if you write it like this:
"^$var,"
bash will expand it this way: "^'value of variable named var,'" which would result in a blank value since the variable is var and not var, giving this end result : "^"
if you use the curly brace instead like this:
"^${var},"
bash will look for a variable var and append ^ at the start and a , at the end giving you this value after expansion "^'var value',"
so with
var=foo
you would get "^foo," as your grep pattern

How to pass the values of a file in a shell variable so that the variable can be used in a url for multiple values

I have a file mwwtesrepos.xml with values as
$cat mwwtesrepos.xml
test1
test2
test3
And I want to pass the values of the file mwwtesrepos.xml, one by one, in the Base_Url.
I have tried the following, but it's not working:
value=$(cat mwwtesrepos.xml)
echo $value
Base_Url="https://stash-url/rest/api/1.0/projects/MWWTES/repos/$value/permissions/groups?permission=1000"
Like this:
while read -r value
do
Base_Url="https://stash-url/rest/api/1.0/projects/MWWTES/repos/$value/permissions/groups?permission=1000"
echo $Base_Url
done < mwwtesrepos.xml
cat is sometimes useful in a script, but more often it is misused.

Literal text not recognized in if statement

I'm trying to spit this text out but the view is not recognizing the text "Test1 Test2, test3 test 4":
<h3>#if(#user != null){#user.FullName Test1 Test2, Test3 Test4 #user.LastSignIn.}</h3>
You might want to surround it with <text></text> tags
<h3>#if(#user != null){#user.FullName <text>Test1 Test2, Test3 Test4 </text>
#user.LastSignIn.}</h3>

Resources