Friday, May 20, 2016

Workaround for creating chart from messages with non-numeric fields in Graylog

As we all know, Graylog doesn't support creating a chart on non-numeric value at the moment. There is a neat workaround suggested by Drew Miranda that can fulfil this functionality. I'll try to rephrase it step by step.

  1. Go to Graylog UI page
  2. Make a search for the field and value that you want to represent as a chart
  3. Around the bottom left corner of search page, click all fields
  4. Find timestamp field and generate chart from it
  5. Around top right of the chart, Customize > Value > Total
That's it for a single value chart. But if you want a chart to contain multiple values, keeps going
  1. Redo 2-5 again for different fields
  2. Click and hold on hamburger menu button at the top right of each, drag to merge them
That's neat right?

Thursday, May 19, 2016

Add local registry mirror to docker daemon on systemd ubuntu (after 15.04)

After docker installation, follow this steps

  • Create directory /etc/systemd/system/docker.service.d if not exist
  • Create mirror.conf file inside that directory. The name "mirror" can be changed to anything.
  • In the file, add this lines
ExecStart=/usr/bin/docker daemon -H fd:// --registry-mirror=http://registry-host:registry-port
  • registry-host is hostname/ip of your local registry mirror
  • registry-port is port of your local registry mirror
  • Flush the change with $ sudo systemctl daemon-reload
  • Restart docker with $ sudo systemctl restart docker
  • Check if the change is successfully applied with $ systemctl status docker,  your config should appear somewhere in the command output.
Tested on Docker 1.11, Ubuntu 15.10 & 16.04

If you want more explanations about these commands, please refer to follow links. Thank you for all of them for providing me a direction to solve the issue and also come up with this post.

Thursday, May 12, 2016

Delete unused (orphaned) Docker volume

Since Docker 1.9, there's an easy way to find unused volumes and delete them.

To list unused volumes, use this command

$ docker volume ls -qf dangling=true

To delete them, use

$ docker volume rm $(docker volume ls -qf dangling=true)

Credit: I copied the whole thing from this SO answer

Tuesday, May 10, 2016

[Fixed] WARN Not all child routes satisfy compojure.api.routing/Routing. {:path nil, :method nil}, invalid child routes:

I had this error in my client app that uses compojure-api. The cause of this problem is that I put the static assets routing configuration in the wrong place. We put (route/resources "/") inside defapi which is a place for api routing configurations. So to fix this, we create a defroutes for static assets routing config and merge this defroutes with defapi before giving it to webserver as a ring handler. At the end, the code look something like this.

(ns my.namespace
  (:require [compojure.api.sweet :refer [defapi]]
            [compojure.core :refer [defroutes routes]]
            [compojure.route :as route]))

(defapi app

(defroutes site
  (route/resources "/"))

(defn handler []
  (route site app))

Tuesday, April 26, 2016

Set daemon config for Docker for Mac

Just follow what describe in this link How to run a insecure-registry

Capture the screen in case the link is gone in the future

Unix, use output of the previous command

Not a direct solution but it suits my need.
Use !! to expand the previous command and evaluate it with $() or ``
For example;

$ which pinata  
$ ls -lh `!!`

Thursday, February 25, 2016

Interesting use case example for `are` macro in Clojure test

I found an interesting use case for are in Clojure test.

You might have ever written a test for your data conversion logic. E.g.
  • Converting data pulled from third-party web service into your internal schema.
  • Converting data fetched from your database to more mobile friendly schema before sending out.
This is an example snippet of test for such a scenario.

convert-test1 shows the style I had been writing until recently. convert-test2 shows how using are making the test better.

  • No more duplication of field values between input and output.
  • No more duplication between output schema and code under test schema.
  • It can be use as a document showing clearly how each individual field is mapped.
An error message in convert-test1 is better. It shows clearly which field is wrong while convert-test2 throw out the whole problematic result data.

Updated: I have retested, are does report problem for an individual case as well.