If condition in Emal Callback - Graylog Opensoure - email

Anyone that have exp about configuring email callback on Graylog, please advise me this case.
In log that we receive have field: protocol-id. Now I can using it in email by using syntax:
${message.fields.protocol-id}.
But value of this filed is number. I want to change it to string. I give example:
if (protocol-id = 17) protocol-id = 'UDP'.
I try code as below but I don't get anything:
${if ${message.fields.protocol-id}==17}Protocol-Attack: UDP
How I can solve this case???

You can create a stream which contains only those messages (e. g. by adding a stream rule "Field protocol-id must be equal to 17"), call it "Protocol-Attack: UDP", and then create an alert condition for this specific stream which will fire if there are any messages in this stream.

Related

Is there a way to have plain text/string as an activity output in Azure Data Factory

I have a set of if Conditions where if they are true, they send out an email, I have set an alert that if all conditions are false, it will send out an email saying this.
I have a Fail activity for false in each of the if conditions, so I can set an output, however even when an email is sent, it says the pipeline fails. The issue here is that if the pipeline fails, it sends out an email saying it failed. Is there a way to format the false output so that it shows a success rather than a fail whilst also having in mind that I need an output for each condition so if they all are false, it sends out an email saying no condition is met?
You can create a pipeline variable and use the Set Variable activity inside the false case to add your plain text or description to that variable. You can use this variable in later activities.
You can use the Switch activity for validating multiple conditions and use other activities for each case.
Refer to this document for more information.

FIXT1.1 ERROR_MISSING_EXECUTINGTRADER PartyRole

New Order Single(D)
Request-
FIXT.1.1:135->PSE, outgoing> (8=FIXT.1.19=14635=D34=449=SendercompId52=20191226-05:19:22.66156=TargetCompId11=157733756231838=10040=154=155=2GO59=060=20191226-13:19:22.645447=I448=135452=3453=010=253)
Response-
FIXT.1.1:135->PSE, incoming> (8=FIXT.1.19=00020535=849=SendercompId56=TargetCompId34=452=20191226-05:19:22.73537=NONE11=157733756231817=TE5368150=839=8103=9955=2GO54=138=10040=1151=014=060=20191226-05:19:22.73158=ERROR.MISSING_EXECUTINGTRADER PartyRole10=240)
ERROR.MISSING_EXECUTINGTRADER PartyRole
Kindly suggest with a proper example which gives correct response for New Order Single(D)
Kindly gives actual values related to parties
quickfix.fix50sp1.NewOrderSingle newOrderSingle = new quickfix.fix50sp1.NewOrderSingle(new ClOrdID(order.getID()),
sideToFIXSide(order.getSide()), new TransactTime(), typeToFIXType(order.getType()));
newOrderSingle.setField(new NoPartyIDs(?));
newOrderSingle.setField(new PartyRole(?));
newOrderSingle.setField(new PartyIDSource('?'));
newOrderSingle.setField(new PartyID("?"));
- List item
Fundamental part of the FIX protocol is the FIX dictionary, which is part of Rules of Engagement (RoE) between your system and the Execution Venue (aka Broker or Counterparty). It specifies what messages are part of the protocol and what fields are required on specific messages in specific scenarios, specifically, what fields are required on the New Order Single (35=D) message.
In your case, the text (tag 58) of the reject message, Execution Report (35=9|39=8) indicates that your application is not sending a mandatory tag PartyRole (452) on the request: 58=ERROR.MISSING_EXECUTINGTRADER PartyRole. But there will be more of them and you should really start from reading the Broker's ROE.
If you are just playing with FIX and coding both ends of the session yourself, check what fields are in use in the QuickFIXj Examples or in examples in my FIXGlue repository. It should get you going.

Send an email when a boolean is true

I am trying to send an email whenever a boolean value equals. The email needs to contain info from a list that is created in a groovy script earlier in the job. whenever this list isn't empty I will need to create a text/HTML email with the contents of the list.
currently I have the email extension plugin but I can't find a way to integrate it with what I need. Is there anyway I could send the email using groovy or use a plugin that triggers based on what I need?
To anyone who it may concern, I discovered that with the Flexible Publish Plug in you can add conditionals to your post build actions, easiest to use string values and just compare those. this is because you can set up parameters at the start of your build that you plan to use to store info in the build environment, and it can be accessed from other places.
you can set string params using the following code:
def paramTempHolder = new StringParameterValue('PARAM', 'desired value')
build.replaceAction(new ParametersAction(paramTempHolder))
for me I used send to indcate I needed to send my email so my code read:
def paramTempHolder = new StringParameterValue('SendEmail', 'send')
I then used $SendMail as string 1 in flexible publish and just send as string 2. If the condition is meet it will send my email. I can use the same parameter manipulation to get the info I need into my email so that it sends like I want it to.
EDIT: I forgot to mention that inorder to use the replaceAction method you will need to add the following import to your script:
import hudson.model.*

Is there a way to fetch latest email from "Mail reader sampler" or "Beanshell Sampler"

I am able to fetch email from my email account using POP3 via "Mail Reader Sampler" listener. But its not retrieving latest email.
Is it possible to extract the latest email using Beanshell Sampler. If yes, can you please share the code if this is achievable.
As per below discussion - looks like it is not doable. But, wanted to check if this is achievable using any means?
Stackoverflow Discussion on how to fetch required email
You can do this programmatically, check out the following methods:
Folder.getMessageCount() - Get total number of messages in this Folder
Folder.getMessage(int msgnum) - Get the Message object corresponding to the given message number
According to the JavaDoc
Messages are numbered starting at 1 through the total number of message in the folder.
So the number of the last message will always be the same as the total number of messages in the given folder.
Example code which reads last email using POP3 protocol
import javax.mail.Folder
import javax.mail.Message
import javax.mail.Session
import javax.mail.Store
String host = "host"
String user = "username"
String password = "password"
Properties properties = System.getProperties();
Session session = Session.getDefaultInstance(properties)
Store store = session.getStore("pop3")
store.connect(host, user, password)
Folder inbox = store.getFolder("Inbox")
inbox.open(Folder.READ_ONLY)
int msgCount = inbox.getMessageCount()
Message last = inbox.getMessage(msgCount)
//do what you need with the "last" message
inbox.close(true)
store.close()
I would also recommend forgetting about Beanshell, whenever you need to perform scripting - use JSR223 Elements and Groovy language as Groovy has much better performance, it is more Java-compliant and it has some nice language features. See Apache Groovy - Why and How You Should Use It guide for more details.

IBM Watson - Conversation Response Condition

I'm pretty new to Watson Conversation and Watson in generel, and I've come across a situation that I would like to handle in the Watson Conversation app, but I can't figure out.
Basically I want to add an "advanced" condition to a response so it will be possible to do e.g.:
Condition: if #sys-number==Integer
Response: #sys-number is an integer.
Condition if #sys-number==Double
Response: #sys-number is a double.
Currently I'm stuck, since I can get the #sys-number class by doing #sys-number.numeric_value.class, which evaluates to e.g. "class java.lang.Integer", but I cannot do the comparison in the condition field.
I've tried to do several different things, where the most obvious would be
if (#sys-number instanceof java.lang.Integer)
I know that this can be handled on the application side, but would like a solution Conversation side, if possible.
By essence the '#sys-number' entity is a string, because it belongs to the user's input.
So if you want to test wether the user's input recognized #sys-number entity can be converted onto integer or a float you must try :
IF #sys-number AND input.text.find('\d+')
IF #sys-number AND input.text.find('\d+[,\.]\d+')
If and only if none of the condition is triggered, the #sys-number comes from Alphabetic input
Use a regular expressions for example the following will look for an integer.
/^[0-9]*$/