Skip to content

Instantly share code, notes, and snippets.

@ravindu
ravindu / prometheus.yml
Created July 6, 2019 12:25
Prometheus Configuration File
# my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
@ravindu
ravindu / logstash-sample.conf
Created November 4, 2018 12:49
Grok pattern for test in Local
input {
stdin {
}
}
filter{
grok {
match => { "message" => "%{TIMESTAMP_ISO8601:logDate} \[%{LOGLEVEL:logLevel}\] TIMESTAMP:%{NUMBER:timestamp},MODULE_NAME:%{NOTSPACE:moduleName},THREAD:%{INT:thread},PID:%{INT:processId},CLASS:%{NOTSPACE:className},METHOD_NAME:%{NOTSPACE:methodName},CUSTOMER_ID:%{NOTSPACE:customerId},APPLICATION_ID:%{NOTSPACE:applicationId},USER_ID:%{NOTSPACE:userId},SESSION_ID:%{NOTSPACE:sessionId},TURN_ID:%{NOTSPACE:turnId},LOG_MESSAGE:%{GREEDYDATA:logMessage}" }
}
if "_grokparsefailure" in [tags] {
@ravindu
ravindu / logstashConfiguration.conf
Last active November 4, 2018 12:12
Grok Filter Example
input {
beats {
port => "5044"
}
}
filter{
grok {
match => { "message" => "%{TIMESTAMP_ISO8601:logDate} \[%{LOGLEVEL:logLevel}\] TIMESTAMP:%{NUMBER:timestamp},MODULE_NAME:%{NOTSPACE:moduleName},THREAD:%{INT:thread},PID:%{INT:processId},CLASS:%{NOTSPACE:className},METHOD_NAME:%{NOTSPACE:methodName},CUSTOMER_ID:%{NOTSPACE:customerId},APPLICATION_ID:%{NOTSPACE:applicationId},USER_ID:%{NOTSPACE:userId},SESSION_ID:%{NOTSPACE:sessionId},TURN_ID:%{NOTSPACE:turnId},LOG_MESSAGE:%{GREEDYDATA:logMessage}" }
}
if "_grokparsefailure" in [tags] {
@ravindu
ravindu / RetryService.java
Created July 5, 2018 07:58
A service which is going to apply the Spring Retry implentation
package com.example.retry.service;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.retry.RecoveryCallback;
import org.springframework.retry.RetryCallback;
import org.springframework.retry.RetryContext;
import org.springframework.retry.support.RetryTemplate;
import org.springframework.stereotype.Service;
@ravindu
ravindu / RetryTempleteConfiguration.java
Created July 5, 2018 07:48
RetryTemplete Configuration
package com.example.retry.infrastructure.configuration;
import java.util.HashMap;
import java.util.Map;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.retry.annotation.EnableRetry;
import org.springframework.retry.backoff.FixedBackOffPolicy;
import org.springframework.retry.policy.SimpleRetryPolicy;
@ravindu
ravindu / gist:24685884175f845f59b68adda2f8cb77
Created July 1, 2018 17:23
JavaMail configuration properties
##################################
#### email configuration ######
##################################
email.configuration.transportprotocol=smtp
email.configuration.smtp.auth=true
email.configuration.smtp.host=smtp.gmail.com
email.configuration.smtp.port=587
email.configuration.smtp.starttls=true
email.configuration.smtp.connectiontimeout=60000
email.configuration.smtp.timeout=60000
@ravindu
ravindu / SecureEmailServiceImpl.java
Created July 1, 2018 17:09
JavaMail implementation with text and attachment support
package com.example.secureemailconnector.infrastructure.service;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.mail.Address;
import javax.mail.AuthenticationFailedException;
import javax.mail.BodyPart;
@ravindu
ravindu / SecureEmailService.java
Created July 1, 2018 16:52
SecureEmailService Interface
package com.example.secureemailconnector.domain.message;
public interface SecureEmailService {
public SecureEmailResponse sendEmail(SecureEmailRequest emailRequest);
}
@ravindu
ravindu / JavamailConfiguration.java
Created July 1, 2018 16:47
Javamail Spring configuration class
package com.example.secureemailconnector.infrastructure.configuration;
import java.util.Properties;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ravindu
ravindu / ClientLogsManagementControllerTest.java
Last active July 1, 2018 06:17
ClientLogsManagementController MockMvc Junit test
package com.example.integration.logging;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.asyncDispatch;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import java.util.HashMap;
import java.util.Map;