Skip to content

Instantly share code, notes, and snippets.

@wozniakjan
Last active August 10, 2017 15:03
Show Gist options
  • Save wozniakjan/77f354a483a11d35f2875a9090e36e4f to your computer and use it in GitHub Desktop.
Save wozniakjan/77f354a483a11d35f2875a9090e36e4f to your computer and use it in GitHub Desktop.
events
{
"_index" : ".operations.2017.08.07",
"_type" : "com.redhat.viaq.common",
"_id" : "AV28LhKeHnu-8fxLW30H",
"_score" : 1.0,
"_source" : {
"docker" : {
"container_id" : "020f49711f0d441dbeec0665a8ebd702aa6ec4ffc829aa2bd69f79c6a211b00e"
},
"kubernetes" : {
"event" : {
"verb" : "ADDED",
"metadata" : {
"name" : "java-mainclass-1.14d888a4cfc24890",
"namespace" : "javaj",
"selfLink" : "/api/v1/namespaces/javaj/events/java-mainclass-1.14d888a4cfc24890",
"uid" : "d828ac69-7b58-11e7-9cf5-5254002f560c",
"resourceVersion" : "311987",
"creationTimestamp" : "2017-08-07T10:11:57Z"
},
"involvedObject" : {
"kind" : "ReplicationController",
"namespace" : "javaj",
"name" : "java-mainclass-1",
"uid" : "e6bff941-76a8-11e7-8193-5254002f560c",
"apiVersion" : "v1",
"resourceVersion" : "308882"
},
"reason" : "SuccessfulCreate",
"message" : "Created pod: java-mainclass-1-1wd39",
"source" : {
"component" : "replication-controller"
},
"firstTimestamp" : "2017-08-07T10:11:57Z",
"lastTimestamp" : "2017-08-07T10:11:57Z",
"count" : 1,
"type" : "Normal"
},
"container_name" : "kube-eventrouter",
"namespace_name" : "default",
"pod_name" : "logging-eventrouter-2-7sgxj",
"pod_id" : "0e4b95d2-7b44-11e7-9cf5-5254002f560c",
"labels" : {
"component" : "eventrouter",
"deployment" : "logging-eventrouter-2",
"deploymentconfig" : "logging-eventrouter",
"logging-infra" : "eventrouter",
"provider" : "openshift"
},
"host" : "fed2",
"master_url" : "https://kubernetes.default.svc.cluster.local",
"namespace_id" : "46f37f2e-3fa8-11e7-a651-5254002f560c"
},
"hostname" : "fed2",
"message" : "{\"verb\":\"ADDED\",\"event\":{\"metadata\":{\"name\":\"java-mainclass-1.14d888a4cfc24890\",\"namespace\":\"javaj\",\"selfLink\":\"/api/v1/namespaces/javaj/events/java-mainclass-1.14d888a4cfc24890\",\"uid\":\"d828ac69-7b58-11e7-9cf5-5254002f560c\",\"resourceVersion\":\"311987\",\"creationTimestamp\":\"2017-08-07T10:11:57Z\"},\"involvedObject\":{\"kind\":\"ReplicationController\",\"namespace\":\"javaj\",\"name\":\"java-mainclass-1\",\"uid\":\"e6bff941-76a8-11e7-8193-5254002f560c\",\"apiVersion\":\"v1\",\"resourceVersion\":\"308882\"},\"reason\":\"SuccessfulCreate\",\"message\":\"Created pod: java-mainclass-1-1wd39\",\"source\":{\"component\":\"replication-controller\"},\"firstTimestamp\":\"2017-08-07T10:11:57Z\",\"lastTimestamp\":\"2017-08-07T10:11:57Z\",\"count\":1,\"type\":\"Normal\"}}\n",
"pipeline_metadata" : {
"collector" : {
"ipaddr4" : "10.128.1.207",
"ipaddr6" : "fe80::1c0c:1fff:feef:4e16",
"inputname" : "fluent-plugin-in_tail",
"name" : "fluentd openshift",
"received_at" : "2017-08-07T10:11:57.203593565Z",
"version" : "0.12.37 1.6.0"
}
},
"level" : "info",
"@timestamp" : "2017-08-07T10:11:57.000000+00:00"
}
}
{
"_index" : ".operations.2017.08.07",
"_type" : "com.redhat.viaq.common",
"_id" : "AV28LhKeHnu-8fxLW30H",
"_score" : 1.0,
"_source" : {
"docker" : {
"container_id" : "020f49711f0d441dbeec0665a8ebd702aa6ec4ffc829aa2bd69f79c6a211b00e"
},
"kubernetes" : {
"event" : {
"verb" : "ADDED",
"metadata" : {
"name" : "java-mainclass-1.14d888a4cfc24890",
"selfLink" : "/api/v1/namespaces/javaj/events/java-mainclass-1.14d888a4cfc24890",
"uid" : "d828ac69-7b58-11e7-9cf5-5254002f560c",
"resourceVersion" : "311987",
"creationTimestamp" : "2017-08-07T10:11:57Z"
},
"involvedObject" : {
"kind" : "ReplicationController",
"uid" : "e6bff941-76a8-11e7-8193-5254002f560c",
"apiVersion" : "v1",
"resourceVersion" : "308882"
},
"reason" : "SuccessfulCreate",
"source" : {
"component" : "replication-controller"
},
"firstTimestamp" : "2017-08-07T10:11:57Z",
"lastTimestamp" : "2017-08-07T10:11:57Z",
"count" : 1,
"type" : "Normal"
},
"container_name" : "java-mainclass-1", # overriden by kubernetes.event.involvedObject.name
"namespace_name" : "javaj", # overriden by kubernetes.event.involvedObject.namespace
"pod_name" : "logging-eventrouter-2-7sgxj",
"pod_id" : "0e4b95d2-7b44-11e7-9cf5-5254002f560c",
"labels" : {
"component" : "eventrouter",
"deployment" : "logging-eventrouter-2",
"deploymentconfig" : "logging-eventrouter",
"logging-infra" : "eventrouter",
"provider" : "openshift"
},
"host" : "fed2",
"master_url" : "https://kubernetes.default.svc.cluster.local",
"namespace_id" : "46f37f2e-3fa8-11e7-a651-5254002f560c"
},
"hostname" : "fed2",
"message" : "Created pod: java-mainclass-1-1wd39", # overriden by kubernetes.event.message
"pipeline_metadata" : {
"collector" : {
"ipaddr4" : "10.128.1.207",
"ipaddr6" : "fe80::1c0c:1fff:feef:4e16",
"inputname" : "fluent-plugin-in_tail",
"name" : "fluentd openshift",
"received_at" : "2017-08-07T10:11:57.203593565Z",
"version" : "0.12.37 1.6.0"
}
},
"level" : "info",
"@timestamp" : "2017-08-07T10:11:57.000000+00:00"
}
}
{
"object": {
"apiVersion": "v1",
"count": 1,
"firstTimestamp": "2017-08-07T10:11:57Z",
"involvedObject": {
"apiVersion": "v1",
"kind": "ReplicationController",
"name": "java-mainclass-1",
"namespace": "javaj",
"resourceVersion": "308882",
"uid": "e6bff941-76a8-11e7-8193-5254002f560c"
},
"kind": "Event",
"lastTimestamp": "2017-08-07T10:11:57Z",
"message": "Created pod: java-mainclass-1-1wd39",
"metadata": {
"creationTimestamp": "2017-08-07T10:11:57Z",
"name": "java-mainclass-1.14d888a4cfc24890",
"namespace": "javaj",
"resourceVersion": "311987",
"selfLink": "/api/v1/namespaces/javaj/events/java-mainclass-1.14d888a4cfc24890",
"uid": "d828ac69-7b58-11e7-9cf5-5254002f560c"
},
"reason": "SuccessfulCreate",
"source": {
"component": "replication-controller"
},
"type": "Normal"
},
"type": "ADDED"
}
{
"_index" : ".operations.2017.08.07",
"_type" : "com.redhat.viaq.common",
"_id" : "AV28LhKeHnu-8fxLW30H",
"_score" : 1.0,
"_source" : {
"verb" : "ADDED",
"event" : {
"metadata" : {
"name" : "java-mainclass-1.14d888a4cfc24890",
"namespace" : "javaj",
"selfLink" : "/api/v1/namespaces/javaj/events/java-mainclass-1.14d888a4cfc24890",
"uid" : "d828ac69-7b58-11e7-9cf5-5254002f560c",
"resourceVersion" : "311987",
"creationTimestamp" : "2017-08-07T10:11:57Z"
},
"involvedObject" : {
"kind" : "ReplicationController",
"namespace" : "javaj",
"name" : "java-mainclass-1",
"uid" : "e6bff941-76a8-11e7-8193-5254002f560c",
"apiVersion" : "v1",
"resourceVersion" : "308882"
},
"reason" : "SuccessfulCreate",
"message" : "Created pod: java-mainclass-1-1wd39",
"source" : {
"component" : "replication-controller"
},
"firstTimestamp" : "2017-08-07T10:11:57Z",
"lastTimestamp" : "2017-08-07T10:11:57Z",
"count" : 1,
"type" : "Normal"
},
"docker" : {
"container_id" : "020f49711f0d441dbeec0665a8ebd702aa6ec4ffc829aa2bd69f79c6a211b00e"
},
"kubernetes" : {
"container_name" : "kube-eventrouter",
"namespace_name" : "default",
"pod_name" : "logging-eventrouter-2-7sgxj",
"pod_id" : "0e4b95d2-7b44-11e7-9cf5-5254002f560c",
"labels" : {
"component" : "eventrouter",
"deployment" : "logging-eventrouter-2",
"deploymentconfig" : "logging-eventrouter",
"logging-infra" : "eventrouter",
"provider" : "openshift"
},
"host" : "fed2",
"master_url" : "https://kubernetes.default.svc.cluster.local",
"namespace_id" : "46f37f2e-3fa8-11e7-a651-5254002f560c"
},
"hostname" : "fed2",
"message" : "{\"verb\":\"ADDED\",\"event\":{\"metadata\":{\"name\":\"java-mainclass-1.14d888a4cfc24890\",\"namespace\":\"javaj\",\"selfLink\":\"/api/v1/namespaces/javaj/events/java-mainclass-1.14d888a4cfc24890\",\"uid\":\"d828ac69-7b58-11e7-9cf5-5254002f560c\",\"resourceVersion\":\"311987\",\"creationTimestamp\":\"2017-08-07T10:11:57Z\"},\"involvedObject\":{\"kind\":\"ReplicationController\",\"namespace\":\"javaj\",\"name\":\"java-mainclass-1\",\"uid\":\"e6bff941-76a8-11e7-8193-5254002f560c\",\"apiVersion\":\"v1\",\"resourceVersion\":\"308882\"},\"reason\":\"SuccessfulCreate\",\"message\":\"Created pod: java-mainclass-1-1wd39\",\"source\":{\"component\":\"replication-controller\"},\"firstTimestamp\":\"2017-08-07T10:11:57Z\",\"lastTimestamp\":\"2017-08-07T10:11:57Z\",\"count\":1,\"type\":\"Normal\"}}\n",
"pipeline_metadata" : {
"collector" : {
"ipaddr4" : "10.128.1.207",
"ipaddr6" : "fe80::1c0c:1fff:feef:4e16",
"inputname" : "fluent-plugin-in_tail",
"name" : "fluentd openshift",
"received_at" : "2017-08-07T10:11:57.203593565Z",
"version" : "0.12.37 1.6.0"
}
},
"level" : "info",
"@timestamp" : "2017-08-07T10:11:57.000000+00:00"
}
}
def move(hash, src, dst)
src_obj = src.inject(hash) { |src_hsh, i|
return nil if src_hsh[i] == nil
src_hsh[i]
}
dst_i = dst.pop
dst_hsh = dst.inject(hash) { |dst_hsh, i|
dst_hsh[i] = Hash.new unless dst_hsh[i].is_a?(Hash)
dst_hsh[i]
}
dst_hsh[dst_i] = src_obj
end
move(record, ["kubernetes","event","message"], ["message"])
move(record, ["kubernetes","source","component"], ["kubernetes","source_component"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment