I want to filter out payload if it contains following error codes 202048
202049 200003
filter --expression=payload.contains('202048')||payload.contains('202049')||payload.contains('200003')
Can i put or condition in my expression || is my or
See the SpEL language reference.
Use OR (or or).
You need spaces around the or so you need to quote the whole expression; since the module is likely within a string, you will need to escape the literal quotes. For example:
xd:>stream create foo --definition "time |
filter --expression='payload.endsWith(\"0\") OR payload.endsWith(\"1\")'| log" --deploy
Related
I have an API that contains a customer ID value, that is generated randomly and contains special character.
I need to assert this customer ID using Response Assertion, But due to the special characters , the comparison shows fail .
Example:
API body:
{Customer_ID : "rzrzlk#kad9$l11zr#zz9dr1"
}
My response assertion:
"data":[{"customer_id":"rzrzlk#kad9$l11zr#zz9dr1",
Result:
Assertion failed
I know I should user backslash , but when you dont know where to user it inside the values, it will be useless.
You should use a backslash only if you're escaping regular expressions meta characters
If you just need to ensure that response contains the given value you should use the following setup:
Contains and Matches modes expect a regular expression
Equals and Substring modes expect a plain text string
More information: How to Use JMeter Assertions in Three Easy Steps
I have an Html page which contains many script tags and inside each script tag I have a structure like:
<script>window.pagedata={listItems:[{"name": "Multi-Warna Lembut Silikon Casing Ponsel Untuk Apple iPhone 11 Case 11 Pro Max Tidak Berbau dan Tidak Beracun Casing iPhone 11 pro-Max"}]}</script>
My goal is to extract all the name from this script tag using a regex or a x-path in JMeter.
You can extract name using below regular expression. Please note that if your requirement is to extract any one product name from response (assuming you have lot of product names in response), you can put match No. as "0" (which selects randomly). Else, if you need product name which comes at first occurrence, you can define match no as "1".
Regular Expression : \{"name": "(.*?)"\}
If your goal is to extract all names, then please use "-1" in match No. Variable substitution will be ${name_1}, ${name_2} ..etc;
You can use regulare expression extractior post processor and refer to the regex as shown below.
Result:
Add Regular Expression Extractor as a child of the request which returns the names, you're looking for
Configure it as follows:
Name of created variable: anything meaningful, i.e. name
Regular Expression: {listItems:\[{"name":\s*(.+?)"
Template: $1$
Match No: -1
That's it, you should be able to access the extracted values as ${name_1}, ${name_2}, etc.
Demo (assumes Dummy Sampler to mimic multiple products)
More information: JMeter Regular Expressions
You can pass arguments to an AWS Glue job via the --arguments parameter (see here).
The CloudFormation documentation says DefaultArguments are "UTF-8 string–to–UTF-8 string key-value pairs" and that their type is "JSON object". Since YAML is a super set of JSON, I was expecting to be able to pass arguments like this in a (YAML) CloudFormation template:
DefaultArguments:
"--arguments": {"--test_argument": "foo"}
However, it raises this error during CloudFormation deployment:
Property validation failure: [Value of property {/DefaultArguments/--arguments=} does not match type {String}]
How do I specify the values correctly?
The correct way of passing multiple parameters is
DefaultArguments:
"--argument1": value1
"--argument2": value2
and then accessing them in the job (e.g. in Python) like this:
from awsglue.utils import getResolvedOptions
args = getResolvedOptions(sys.argv, ['argument1', 'argument2'])
print args['argument1']
print args['argument2']
What confused me was that for passing parameters with the AWS CLI, you use an explicit --arguments='--argument1="value1"' structure but in CloudFormation, you specify arguments one by one.
The value for the key --arguments needs to be a string, but you actually give it a mapping (or in JSON-speak an object), because it starts witha {. You should quote the value, and since you have double quotes in the value, you best do that with single quotes:
DefaultArguments:
"--arguments": '{"--test_argument": "foo"}'
(any existing single quotes in the value you would need to escape by putting two single quotes)
If your JSON is more complex it can be benificial to use folded-style scalars. Within those the { has no special meaning either and (single) newlines followed by spaces are replaced by a single space. So the following loads to same data as the solution above:
DefaultArguments:
"--arguments": >
{"--test_argument":
"foo"}
Of course with YAML (1.2) being a superset of JSON, glue could easily assume that a value is already parsed if it is not a string, but it doesn't seem to be that smart and always expects the JSON in string form.
I am a newbie to Pentaho (installed today). I was able to do basic transformation in Spoon. Now I need to do some stuff, which I can't figure out how.
my input looks like
2012-09-17|garima|fbhjgjhgj87687jghgj88jgjj|garima#1347868164626|::ffff:120.56.132.137
3rd field is an ID, for which I need to get some information from a REST API
http://api.app.com/app/api/v1/feature/fbhjgjhgj87687jghgj88jgjj
What do I need to do in Spoon to get this done?
Also, data return will be in json format. how do I parse that?
You should first get your input with a CSV File Input using | as delimiter. Then you can get the 3rd field as a string.
Next you probably need to remove all spaces from this string with a String operations step. Look at the Remove special character column, and select space.
Then you need to concatenate it with your http address http://api.app.com/app/api/v1/feature/. For this you'll use a Calculator step. At this step first create a new temporary field tmpAddr, with operation Define a constant value for ... (or something like this, sorry my spoon is in portuguese). At the Field A column you'll write your http address. It's a good practice, after you make this work, to set your address as a system variable so if it changes you don't need to replace it everywhere on your transformations (look at menu Edit -> System Variables).
Now on the same Calculator step create another field, let's say MyAddress, with operation A+B. Choose for Field A the field tmpAddr you just created, and for Field B the 3rd field from your input.
Now on your stream you should have the full address as a field MyAddress. Connect a REST client step. Mark Accept URL from field and choose field MyAddress as URL Field Name. Set Application Type to JSON. Set Result Fieldname as MyResult.
If you need further JSON parsing you can add a Json input step. Set Source is defined in a field and select field MyResult as Get Source from field.
An alternate approach is to use the "Replace in String" step to append the string.
Set 'use RegEx' to Y
Set 'Search' to (.*)
Set 'Replace with' to http://api.app.com/app/api/v1/feature/$1
Set 'Whole Word' to Y
The parentheses in the regex set up a capture group that you can then insert into your replacement string with the $X syntax
I'm getting a regex headache, so hopefully someone can help me here. I'm doing some file syntax conversion and I've got this situation in the files:
OpenMarker
keyword some expression
keyword some expression
keyword some expression
keyword some expression
keyword some expression
CloseMarker
I want to match all instances of "keyword" inside the markers. The marker areas are repeated and the keyword can appear in other places, but I don't want to match outside of the markers. What I don't seem to be able to work out is how to get a regex to pull out all the matches. I can get one to do the first or the last, but not to get all of them. I believe it should be possible and it's something to do with repeated capture groups -- can someone show me the light?
I'm using grepWin, which seems to support all the bells and whistles.
You could use:
(?<=OpenMarker((?!CloseMarker).)*)keyword(?=.*CloseMarker)
this will match the keyword inside OpenMarker and CloseMarker (using the option "dot matches newline").
sed -n -e '/OpenMarker[[:space:]]*CloseMarker/p' /path/to/file | grep keyword should work. Not sure if grep alone could do this.
There are only a few regex engines that support separate captures of a repeated group (.NET for example). So your best bet is to do this in two steps:
First match the section you're interested in: OpenMarker(.*?)CloseMarker (using the option "dot matches newline").
Then apply another regex to the match repeatedly: keyword (.*) (this time without the option "dot matches newline").