Skip to content

Instantly share code, notes, and snippets.

@monkey-codes
monkey-codes / gist:d2908935000c754c6b87aeecb176b069
Created Aug 8, 2016
Gradle dependencies to setup logstash logback
View gist:d2908935000c754c6b87aeecb176b069
dependencies {
ext {
logbackVersion = '1.1.6'
slf4jApiVersion = '1.7.15'
logStashLogbackEncoderVersion = '4.7'
}
...
compile("ch.qos.logback:logback-classic:$logbackVersion")
compile("ch.qos.logback:logback-core:$logbackVersion")
compile("ch.qos.logback:logback-access:$logbackVersion")
View actuator-grafana-dashboard.json
{
"annotations": {
"list": []
},
"editable": true,
"gnetId": null,
"graphTooltip": 0,
"hideControls": false,
"id": null,
"links": [],
@monkey-codes
monkey-codes / rxjs-pull-vs-push.js
Created Nov 22, 2016
rxjs - Example of Pull vs Push
View rxjs-pull-vs-push.js
//Traditional imperative pull based
window.setInterval(() => {
const tweets = getNewTweets();
for(let tweet of tweets){
if(!tweet.message.contains("Greetings!")) continue;
getUserAvatar(tweet.user)
.then(avatar => {
const $avatar = $(`<img />`);
$avatar.attr('src', avatar.url);
View cloudwatch-metric-filter.yaml
AWSEBCWLGreetingMeanMetricFilter :
Type : "AWS::Logs::MetricFilter"
Properties :
LogGroupName: { "Ref" : "AWSEBCloudWatchLogsAppLogGroup" }
FilterPattern : '{ $.perf4j_tag = "greeting.GET"}'
MetricTransformations :
- MetricValue : $.perf4j_mean
MetricNamespace: {"Fn::Join":["/", ["elastic-beanstalk", {"Ref":"AWSEBEnvironmentName"}]]}
MetricName : greeting-mean
View perf4j-event.json
{
"@timestamp":"2016-08-13T15:43:28.826+1000",
"@version":1,
"message":"greeting.GET=mean[0.25] stddev[1.0897247358851685] min[0] max[5] count[20]",
"logger_name":"org.perf4j.TimingLogger",
"thread_name":"perf4j-async-stats-appender-sink-perf-summary",
"level":"INFO",
"level_value":20000,
"perf4j_tag":"greeting.GET",
"perf4j_max":5,
View logback.groovy
appender('perf-summary', LogstashAsyncCoalescingStatisticsAppender) {
timeSlice = 30000
queueSize = 30000
createRollupStatistics = false
appender(LoggingEventAsyncDisruptorAppender) {
appender(ConsoleAppender) {
encoder(CloudwatchLogstashEncoder) {
customFields = loggingMarkers
shortenedLoggerNameLength = 36
}
View cloudwatch-logs.json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents",
"logs:DescribeLogStreams",
View cwl-metrics.yaml
Mappings:
CWLogs:
WebRequestLogGroup:
TimestampFormat: "%Y-%m-%dT%H:%M:%S.%f%z"
Outputs:
WebRequestCWLogGroup:
Description: "The name of the Cloudwatch Logs Log Group created for this environments web server access logs. You can specify this by setting the value for the environment variable: WebRequestCWLogGroup. Please note: if you update this value, then you will need to go and clear out the old cloudwatch logs group and delete it through Cloudwatch Logs."
Value: { "Ref" : "AWSEBCloudWatchLogsAppLogGroup"}
View logback-access.xml
<configuration>
<define name="app_name" class="codes.monkey.logging.LoggingTagsPropertyDefiner">
<property>app.name</property>
</define>
<define name="app_version" class="codes.monkey.logging.LoggingTagsPropertyDefiner">
<property>app.version</property>
</define>
<define name="eb_hostname" class="codes.monkey.logging.BeanStalkPropertyDefiner">
<field>hostname</field>
</define>
View CloudwatchLoggingApplication.groovy
@SpringBootApplication
class CloudwatchLoggingApplication {
@Bean
EmbeddedServletContainerFactory servletContainer(TomcatContextCustomizer customizer) {
def factory = new TomcatEmbeddedServletContainerFactory()
factory.setTomcatContextCustomizers([customizer])
factory
}