I must be missing something simple with this JSON Configuration Variable feature. I have the following JSON:
{
"EventProcessorFactory": "Factory"
"HubConfiguration": [
{
"ArchiveStorageConnectionString": "Connection string"
"ArchiveStorageContainerName": "containerName"
"EventHubGroupName": "ehs-peds-dev"
}
],
"HeartBeatConfiguration": {
"EventHubGroupName": "GroupName",
"EventHubName": "HubName"
"SharedAccessKey": "AccessKey"
"SharedAccessKeyName": "EventPublishers",
"EndPointURL": "URL"
}
}
I want to replace the ArchiveStorageConnectionString (and other properties of HubConfiguration) but I can't figure out what the correct syntax is. HubConfiguration is an array of HubConfigurations (although in this case I only have 1).
I've tried
HubConfiguration:1:ArchiveStorageConnectionString
But that doesn't work. I've also tried
HubConfiguration:0:ArchiveStorageConnectionString
0:HubConfiguration:0:ArchiveStorageConnectionString
1:HubConfiguration:1:ArchiveStorageConnectionString
but none of this seem to work. Any pointers would be greatly appreciated.
The Octopus code that matches and replaces the variables is here:
https://github.com/OctopusDeploy/Calamari/blob/949008eaaafb8865305c7760e8f8448a5eaabb1a/source/Calamari/Integration/JsonVariables/JsonConfigurationVariableReplacer.cs
Some unit tests are here:
https://github.com/OctopusDeploy/Calamari/blob/949008eaaafb8865305c7760e8f8448a5eaabb1a/source/Calamari.Tests/Fixtures/JsonVariables/JsonConfigurationVariableReplacerFixture.cs
I would have expected this to work:
HubConfiguration:0:ArchiveStorageConnectionString
There does seem to be a problem with your JSON - this line should end with a ,:
"EventProcessorFactory": "Factory"
Do you get any output in your deployment when the convention runs?
I am working with QT 5.5 and I get a json with QNetwork and I try to parse it.
The json object is like this :
{
"cas_version":1008,
"result":"true",
"diaporamas":
{
"0":
{
"diaporamaid":5,
"diaporamamaj":1440433023,
"slides":
{
"0":{"slideid":32,"slidecontent":"html content here"}
}
}
}
If i run my program with this, no problem, the json is correctly parsed.
But if i have more than 10 elements inside slides, i get this error :"illegal value"
The json is generated by PHP5.5
Thank !
Thank you very much, it was not an issue in the json part (which is missing a "}"). The problem was when Qt downloading the file, the file was corrupted (I open the buffer too early)
In soapUI, I am trying to perform an HTTP POST with the following JSON:
{
"myNode":{
"myOtherNode":"${MY_VALUE}"
}
}
The POST operation is successful, but in the response the value for myOtherNode is blank. I'm guessing this is because soapUI is treating it as parameter and trying to replace it. I do not want it replaced; I want to send it as it is.
I am able to do the same thing using command line curl.
Edit: I could not find the answer in their Property Expansion Documentation.
To prevent the property expansion from replacing ${MY_VALUE} you can add an extra $ like this:
{
"myNode":{
"myOtherNode":"$${MY_VALUE}"
}
}
Doing that your original json will be sent like this:
{
"myNode":{
"myOtherNode":"${MY_VALUE}"
}
}
I'm not sure if this is a follow-up or separate question to this one. There is some piece about LogStash that is not clicking. For that, I apologize for a related question. Still, I'm going out of my mind here.
I have an app that writes logs to a file. Each log entry is a JSON object. An example of my .json file looks like the following:
{
"logger":"com.myApp.ClassName",
"timestamp":"1456976539634",
"level":"ERROR",
"thread":"pool-3-thread-19",
"message":"Danger. There was an error",
"throwable":"java.Exception"
},
{
"logger":"com.myApp.ClassName",
"timestamp":"1456976539649",
"level":"ERROR",
"thread":"pool-3-thread-16",
"message":"I cannot go on",
"throwable":"java.Exception"
}
This format is what's created from Log4J2's JsonLayout. I'm trying my damnedest to get the log entries into LogStash. In an attempt to do this, I've created the following LogStash configuration file:
input {
file {
type => "log4j"
path => "/logs/mylogs.log"
}
}
output {
file {
path => "/logs/out.log"
}
}
When I open /logs/out.log, I see a mess. There's JSON. However, I do not see the "level" property or "thread" property that Log4J generates. An example of a record can be seen here:
{"message":"Danger. There was an error","#version":"1","#timestamp":"2014-04-08T17:20:10.035Z","type":"log4j","host":"ip-myAddress","path":"/logs/mylogs.log"}
Sometimes I even get parse errors. I need my properties to still be properties. I do not want them crammed into the message portion or the output. I have a hunch this has something to do with Codecs. Yet, I'm not sure. I'm not sure if I should change the codec on the logstash input configuration. Or, if I should change the input on the output configuration. I would sincerely appreciate any help as I'm getting desperate at this point.
Can you change your log format?
After I change your log format to
{ "logger":"com.myApp.ClassName", "timestamp":"1456976539634", "level":"ERROR", "thread":"pool-3-thread-19", "message":"Danger. There was an error", "throwable":"java.Exception" }
{ "logger":"com.myApp.ClassName", "timestamp":"1456976539649", "level":"ERROR", "thread":"pool-3-thread-16", "message":"I cannot go on", "throwable":"java.Exception" }
One json log per one line and without the "," at the end of the log, I can use the configuration below to parse the json message to correspond field.
input {
file {
type => "log4j"
path => "/logs/mylogs.log"
codec => json
}
}
input {
file {
codec => json_lines { charset => "UTF-8" }
...
}
}
should do the trick
Use Logstash's log4j input.
http://logstash.net/docs/1.4.2/inputs/log4j
Should look something like this:
input {
log4j {
port => xxxx
}
}
This worked for me, good luck!
I think #Ben Lim was right, your Logstash config is fine, just need to properly format input JSON to have each log event in a single line. This is very simple with Log4J2's JsonLayout, just set eventEol=true and compact=true. (reference)
I'm having trouble with parsing my Json, when i place the url in the browser i get this as a return {"token": "7xv6r32eay5n376", "secret": "589bc72ix7mowua"} So all i want to do is get that string and parse out the token and secret and display the values in a notify to confirm i'm getting the correct information. Can anyone see what i'm doing wrong?
rule first_rule {
select when pageview ".*" setting ()
pre{
json=http:get(/* I place my URL here */);
content = json.pick("$..content");
token=content.decode();
tok=token.pick("$..token");
sec=token.pick("$..secret");
message="Token: "+tok+" "+"Secret: "+sec;
}
notify("Values: ",message);
}
}
so i fixed my KRL problem, I guess when using http:get(); you must use double quotes "" not single '' in the get().