I want to see if the community could help me figure out if this is possible.
I'm currently working with a lot of data in Cloudwatch and after getting the search expression to work I was wondering if we could take something like:
[{"expression":
"SEARCH('{AWS/ApiGateway,ApiName} ApiName', 'Average', 300)", "id": "e2"}]
and use it to only return specific ApiName's.
Example being:
test1
test2
test3
data1
data2
data3
Fubar1
I ask this because with the line above it will show all those data in Cloudwatch and that's useful and great but I want to know if I can do something like.
[{"expression":
"SEARCH('{AWS/ApiGateway,ApiName} ApiName = \"test"\', 'Average', 300)", "id": "e2"}]
And have it return just:
test1
test2
test3
I'm reaching out because from documentation it seems like it's not possible and that if I want to do something like this I should maybe look into Log Filters potentially. Anyways thanks for any responses.
If you do ApiName="test" it will match exactly test, but if you remove the double quotes and do ApiName=test it will mach all ApiNames that contain test.
So your expression would be
[ { "expression": "SEARCH('{AWS/ApiGateway,ApiName} ApiName=test', 'Average', 300)", "id": "e2" } ]
See here for more examples:
https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/search-expression-examples.html
Related
I am trying to extract the values from the keys v1 and v2.
I would like it to print like this
first the v1
900
1800
and then v2
700
800
2600
1800
2100
This is how far I have done but I get an error in my second for loop that I do not know how to solve. Is this write scala approach to solve this or is there a better way?
val some_numbers = Map("v1"->(900, 1800),
"v2"->(700, 800, 2600, 1800, 2100))
for ((key,values) <-some_numbers) {
for(value<-values)
print(value)
}
You cannot iterate directly on a tuple value.
I do not know what is your application need. BTW you can iterate on tuple using productIterator:
for ((key,values) <-some_numbers) {
for(value<-values.productIterator) {
println(value)
}
}
This should work. But probably it is better to use List instead of tuple in this case!
Given an input of some objects each containing a set of strings, I want to count the number of occurrences of each string for the entire batch, and output the word counts (to a CSV in my case) alongside each string (preferably sorted by frequency). How can I achieve this in spring batch? I can't find any suitable examples. I've tried to implement this using item readers/processors but am getting the output duplicated, I'm assuming because it's chunked? Should I use Tasklets for this?
Spring Batch : Aggregating records and write count seems close to what I want to achieve, but it's not clear to me how this is working.
The input is along the lines of:
[{
"id": 1,
"tags": ["foo", "bar"]
}, {
"id": 2,
"tags": ["foo", "baz"]
}
...]
and the desired output from that would be
foo, 2
bar, 1
baz, 1
Assuming a mapreduce function representing object relationships like:
function (doc) {
emit([doc.source, doc.target, doc.name], null);
}
The normal example of filtering a compound key is something like:
startKey = [ a_source ]
endKey = [ a_source, {} ]
That should provide a list of all objects referenced from a_source
Now I want the oposite and I am not sure if that is possible. I have not been able to find an example where the variant part comes first, like:
startKey = [ *simbol_first_match* , a_destination ]
endKey = [ {} , a_destination ]
Is that posible? Are compound keys (1) filter and (2) sort operations within a query limited to the order of the elements appear in the key?
I know I could define another view/mapreduce, but I would like to avoid the extra disk space cost if possible.
No, you can't do that. See here where I explained how keys work in view requests with CouchDB.
Compound keys are nothing special, no filtering or anything. Internally you have to imagine that there is no array anymore. It's just syntactic sugar for us developers. So [a,b] - [a,c] is treated just like 'a_b' - 'a_c' (with _ being a special delimiter).
I have an array of arrays in coffe script. How to convert it in easy way to string and then back to array? So i m expecting like this.It's easy to do it in ruby using eval.How to achieve that in a coffe script?
Thanks in advance.
"[[2,3,4],[2,3,4],[4,6,7]]" =>string
and then [[2,3,4],[2,3,4],[4,6,7]] back to an array again
While you could, in theory, use eval in javascript/coffeescript as well, you probably should not. A better solution would probably be to use JSON, for instance:
coffee -e 'console.log JSON.parse(JSON.stringify([[1,2,3],[4,5,6]]));'
which outputs:
[ [ 1, 2, 3 ], [ 4, 5, 6 ] ]
I've read and searched about MongoDB's JSON-BSON constructions but I do not understand (could not find either) how to have nested data and how to query it.
What I'd like to learn is, if somebody wants to store array within an array as in:
id: x,
name: y,
other: z,
multipleArray: [
(lab1: A, lab2: B, lab3:C),
(lab1: AB, lab2: BB, lab3:CB)
(lab1: AC, lab2: BC, lab3:CC)
..
..
]
How to store such data and then retrieve some, a specific or all elements of "multipleArray" contents?
Any resource on the subject would also be highly appreciated.
Bryan had some great advice which you should heed.
Also, as Manoj said, what you actually have is an array of objects. The following might help you out a bit...
Lists are just ordered sequences: [1,2,3...] or [2,292,111]
The first element in the last example is 2, the second is 292... lists/arrays are denoted by square brackets [ ]
Objects map keys to values: { name: "Tyler", age: 26, fav_color: "green" }
name maps to "Tyler", age maps to 25, etc... and objects are denoted by braces { }
A document in mongodb is an object. So, like above, they map keys to values. Those values can be strings, numbers, arrays... or other even other (nested) objects)
So, lets take a look at your document. You have an object (document) that has keys id, name, other, and multipleArray. The value multiple array maps to is an array [ ] of Objects { }.
{
id: x,
name: y,
other: z,
multipleArray: [
{lab1: "A", lab2: "B", lab3:"C"},
{lab1: "AB", lab2: "BB", lab3:"CB"},
{lab1: "AC", lab2: "BC", lab3:"CC"}
]
}
MongoDB has this feature called multikeys, it basically takes the value you are querying for and tries to match it against every value in the array.
If you wanted to find the document where multipleArray contained the document {lab1: "A", lab2: "B", lab3: "C"}, you query like this: db.data.find({multipleArray: {lab1: "A", lab2: "B", lab3: "C"}})
I'm assuming x, y, and z are defined already.
There are more subtleties and complexities, but if you want to learn more read the documentation on the mongodb site here or get a book.
Your question is a bit generic and as such is difficult to give a good answer.
When modeling your data to be stored and queried using MongoDB, you should consider how you plan to actually use and query your data. Based on the answer to that, you should be able to come up with a good data structure for storing the data.
It would be good for you to to familiarize yourself with the MongoDB query methods (http://www.mongodb.org/display/DOCS/Querying) so you can understand the many ways to query data in MongoDB.
Whatever language you are using should have a nice library that should abstract away the low level details of storing and querying the data, but its still going to be important to know what query methods MongoDB supports.
In general, MongoDB queries let you "reach into" nested objects in a given document and that also includes arrays as well.