How to get data from a json response as a variable - jmeter

I tried to get the value of a variable named version (first one) using JSONPath but apparently my solution didn't work at all.
I tried to use an expression like $..version or $.container..version .
My response below:
{
"container" : {
"version" : 8,
"updatedBy" : "user111",
"updatedOn" : "2017-08-17T16:00:24Z",
"id" : 16,
"dataEnt" : {
"dataEntid" : "dataEntid-000032",
"dataEnttype" : "21"
},
"impact" : [ ],
"operationalFocus" : false,
"periodicity" : {
"version" : 0,
"updatedBy" : "unknown",
"updatedOn" : "2017-03-31T16:44:08Z",
"step" : 1,
"period" : 31084132,
"_VALIDATION" : {
"valid" : true,
"saveAll" : true,
"reasons" : [ ],
"details" : {
"period" : {
"valid" : true,
"saveAll" : true,
"risks" : [ ],
"rmiCode" : null,
"rmiMessage" : null
},
"version" : {
"valid" : true,
"saveAll" : true,
"risks" : [ ],
"rmiCode" : null,
"rmiMessage" : null
},
"step" : {
"valid" : true,
"saveAll" : true,
"risks" : [ ],
"rmiCode" : null,
"rmiMessage" : null
}
},
"rmiCode" : null,
"rmiMessage" : null
},
"_META" : { }
}

First of all the JSON you pasted is invalid: it's missing 2 curly brackets at the end (root object and container objects are not closed). If this is not a copy/paste error on SO, but actual data problem, you may need to correct that first.
If I understood correctly, you want the value from this field in the variable:
"version" : 8
If so, JSON path should be:
$.container.version
or
container.version
if you prefer relative path to absolute.
Path like $..version or $.container..version will select multiple version fields ("version" : 0 in periodicity property, and the one that is an object inside _VALIDATION)

The following expression will get you the desired result.
Variable: ContainerVersion
JSON Expression: $..container.version
Now the stored version value can be called using: ${ContainerVersion}
If there are multiple "version" tags are there, then you can load all values of "version" by having following expression,
$..container.version[*]
You can call the variable as ${Var_1}, ${Var_2} etc..
Add debug sampler to see the loaded variable names and its corresponding values.
Hope the above helps...

Related

Error in elasticsearch: Invalid snapshot name snapshot with the same name already in-progress

I have a problem.
I want to store an index that is in elasticsearch. I created a new repository for this and this repository does not have any snapshots. But when I ran the code blog below, it returned me the error message "Invalid snapshot name snapshot with the same name already in-progress ". How can I fix this problem?
I created a new repository with the following code block:
PUT /_snapshot/backup_repository
{
"type": "fs",
"settings": {
"compress" : "true",
"location": "C:/backups/backup_my_index"
}
}
just to be sure i used the code block below and the query returned me this result:
GET /_snapshot/backup_repository/_status
result:
{
"snapshots" : [ ]
}
I wanted to make a backup with the following code block:
PUT /_snapshot/backup_repository/my_snapshot?wait_for_completion=true
{
"indices": "my_index",
"ignore_unavailable": true,
"include_global_state": false,
"metadata": {
"taken_by": "busra duygu",
"taken_because": "backup for my_index"
}
}
Error :
{
"error" : {
"root_cause" : [
{
"type" : "invalid_snapshot_name_exception",
"reason" : "[backup_repository:my_snapshot] Invalid snapshot name [my_snapshot], snapshot with the same name is already in-progress"
}
],
"type" : "invalid_snapshot_name_exception",
"reason" : "[backup_repository:my_snapshot] Invalid snapshot name [my_snapshot], snapshot with the same name is already in-progress"
},
"status" : 400
}
I would be very happy if you could help me.
To see if there is a snapshot that already exist with this name
GET /_snapshot/backup_repository/_all
You will also get the state of it (SUCCESS/FAILED,...)
#ExploZe
As you said i ran this query and it returned me the following result.
Query:
GET /_snapshot/backup_repository/_all
Result:
{
"snapshots" : [
{
"snapshot" : "my_snapshot",
"uuid" : "4Sv055VjQDSZvpBqSvCxpg",
"version_id" : 7100199,
"version" : "7.10.1",
"indices" : [
"my_index"
],
"data_streams" : [ ],
"include_global_state" : false,
"metadata" : {
"taken_by" : "busra duygu",
"taken_because" : "backup for my_index"
},
"state" : "IN_PROGRESS",
"start_time" : "2021-09-09T06:22:16.414Z",
"start_time_in_millis" : 1631168536414,
"end_time" : "1970-01-01T00:00:00.000Z",
"end_time_in_millis" : 0,
"duration_in_millis" : 0,
"failures" : [ ],
"shards" : {
"total" : 0,
"failed" : 0,
"successful" : 0
}
}
]
}

Elasic Existed Query Not working About Empty String

According to Official 7.x document Link
While a field is deemed non-existent if the JSON value is null or [],
these values will indicate the field does exist:
Empty strings, such as "" or "-" Arrays containing null and another
value, such as [null, "foo"] A custom null-value, defined in field
mapping
However, My es not consider "" as not existed.
Here is my Data:
"_source" : {
"chat_msg" : {
"action" : "send",
"from" : "t",
"msgid" : "6505946507184390735_161_external",
"msgtime" : 1623396135015,
"msgtype" : "text",
"roomid" : "",
Now, When I do Query As :
GET enterprise_chat_data/_search
{
"query": {
"bool": {
"must_not": [
{
"exists": {
"field": "chat_msg.roomid"
}
}
]
}
}
}
Result:
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 2,
"successful" : 2,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 0,
"relation" : "eq"
},
"max_score" : null,
"hits" : [ ]
}
}
It Hit Nothing. Am I Wrong About Something?
I think you have misunderstood the documentation. In the documentation, it is written that if a field have value as empty strings, such as "" or "-", then that field will be considered to be existing.
Due to this when you are querying for must_not exists query for "chat_msg.roomid" field, you are getting empty results, as in the data you have indexed the value of "chat_msg.roomid" field as ""
Update 1:
You can use term query to search for documents having field value of chat_msg.roomid as ""
{
"query": {
"term": {
"chat_msg.roomid.keyword": ""
}
}
}

Javers querybuilder for anyDomainObject with commit property filter not working

The Javers JQL to get all domain objects returns empty list.
I've written a wrapper rest api and exposed the Javers commit and getAllShadows api's as below.
#PutMapping("/commit")
public <T> CommitEntity<T> commit(#RequestBody CommitEntity<T> committedObject);
#GetMapping("/getEntityShadows")
public List<EntityShadow> getEntityShadows(#RequestParam(name = "entityId") String entityId);
Now when I use the commit API(above), I'm able to commit my domain object to the repository (mongo)
Sample below:
{
"_id" : ObjectId("5c5f6fb51ebaa93b96edadc8"),
"commitMetadata" : {
"author" : "UserFName UserLname",
"properties" : [
{
"key" : "entityId",
"value" : "user001/US"
}
],
"commitDate" : "2019-02-09T16:26:29.543",
"commitDateInstant" : "2019-02-10T00:26:29.543Z",
"id" : NumberLong(8440229536252376064)
},
"globalId" : {
"valueObject" : "org.javers.core.graph.LiveGraphFactory$MapWrapper"
},
"state" : {
"map" : {
"userId" : {
"id" : "user001",
"locale" : "US"
},
"createdDate" : "2019-02-08T22:16:58",
"Name" : "User Fname",
"address" : {
"state" : "CA",
"country" : "US"
},
"authorName" : "UserFName UserLname",
"lastModifiedBy" : "2019-02-09T16:26:29"
}
},
"changedProperties" : [
"map"
],
"type" : "INITIAL",
"version" : NumberLong(1),
"globalId_key" : "org.javers.core.graph.LiveGraphFactory$MapWrapper/"
}
Now when I try to get all shadows as below, I get back an empty List. I expected to get all the shadows from the repo.
JqlQuery jqlQuery = QueryBuilder.anyDomainObject().withCommitProperty("entityId", "user001/US").build();
List<Shadow<Object>> shadows = javers.findShadows(jqlQuery);
Am I missing anything here?
I tried to just get the shadows with any filter like below, still got back an empty list
JqlQuery jqlQuery = QueryBuilder.anyDomainObject().build();
List<Shadow<Object>> shadows = javers.findShadows(jqlQuery);

Sample outputs of Rumen or Sample input to Gridmix

I am quite new to the use of big data tools like Hadoop. I want to execute a publicly available cluster trace (https://github.com/google/cluster-data) on Yarn/or Yarn Simulator.
One way to do is to feed input into Yarn via Gridmix.
The format in which Gridmix (https://hadoop.apache.org/docs/r2.8.3/hadoop-gridmix/GridMix.html) takes input is basically the output from Rumen.
And Rumen (https://hadoop.apache.org/docs/r2.8.3/hadoop-rumen/Rumen.html) takes JobHistory log generated from a map-reduce cluster as input.
The google trace is not a map-reduce trace. However, I was wondering if I can transform it to the format same as what Grdimix takes as input, then I can use the Grdmix.
Can anyone here point me input format of Gridmix (Or output of Rumen)?
Or suggest me another way to do what I want to do?
Thanks.
The output of Rumen contains two files:
1. job-trace file,
2. cluster-topology file;
those two files are all json format, job-trace file as following format:
{
"jobID" : "job_1546949851050_53464",
"user" : "mammut",
"computonsPerMapInputByte" : -1,
"computonsPerMapOutputByte" : -1,
"computonsPerReduceInputByte" : -1,
"computonsPerReduceOutputByte" : -1,
"submitTime" : 1551801585141,
"launchTime" : 1551801594958,
"finishTime" : 1551801630228,
"heapMegabytes" : 200,
"totalMaps" : 2,
"totalReduces" : 1,
"outcome" : "SUCCESS",
"jobtype" : "JAVA",
"priority" : "NORMAL",
"directDependantJobs" : [ ],
"mapTasks" : [ {
"inputBytes" : 25599927,
...}]
...
}
And, the cluster-topology like:
{
"name" : "<root>",
"children" : [ {
"name" : "rack-01",
"children" : [ {
"name" : "",
"children" : null
}, {
"name" : "",
"children" : null
}, {
"name" : "",
"children" : null
} ]
}, {
"name" : "default-rack",
"children" : [ {
"name" : "x",
"children" : null
} ]
} ]
}

why json.parse inserts a backslash before #

I have a JSON file as following :
[
{"testid" : 1, "desc" : "with valid email", "rescode" : 200, "request" : {"my_user" : {"email" : "#{$user.email}", "password" : "abcde"}, "source" : "android"}},
{"testid" : 2, "desc" : "with valid phone", "rescode" : 200, "request" : {"my_user" : {"phone" : "#{$user.phone}", "password" : "abcde"}, "source" : "android"}}
]
Now, when I try to parse this JSON to get a Hash using JSON.parse(), the content I get has a backslash before the # as follows :
{"housing_user"=>{"email"=>"\\#{$user.email}", "password"=>"abcde"}, "source"=>"android"}
It is preventing me from using the value of $user.email and instead \\#{$user.email} is being used.
How can I prevent this ?

Resources