ORESoftware/bunion

slice from beginning of line

ORESoftware opened this issue · 1 comments

as an example:

echo '
entity-tools-integration-64f7bc9666-wnkmg: new request: GET /styles/font-awesome-4.7.0/css/font-awesome.min.css
entity-tools-integration-64f7bc9666-wnkmg: new request: GET /styles/custom-supply-chain.css
entity-tools-integration-64f7bc9666-wnkmg: new request: GET /scripts/common/jquery-3.3.1.js
entity-tools-integration-64f7bc9666-wnkmg: new request: GET /scripts/common/bootstrap.min.js
'  > (bunion --slice-from-first-index ':')

or:

echo '
entity-tools-integration-64f7bc9666-wnkmg: new request: GET /styles/font-awesome-4.7.0/css/font-awesome.min.css
entity-tools-integration-64f7bc9666-wnkmg: new request: GET /styles/custom-supply-chain.css
entity-tools-integration-64f7bc9666-wnkmg: new request: GET /scripts/common/jquery-3.3.1.js
entity-tools-integration-64f7bc9666-wnkmg: new request: GET /scripts/common/bootstrap.min.js
'  > (bunion --slice-first-index ' ')  # first index of whitespace

likewise, when doing JSON parsing:

g}{172.18.0.4}{172.18.0.4:9300}{dim}{ml.machine_memory=2095673344, ml.max_open_jobs=20, xpack.installed=true},}, term: 5, version: 26, reason: ApplyCommitRequest{term=5, version=26, sourceNode={es02}{iwjzTfguR_-HPcagQpb7gA}{nZtCebDJQF2JzUld2jwW4g}{172.18.0.4}{172.18.0.4:9300}{dim}{ml.machine_memory=2095673344, ml.max_open_jobs=20, xpack.installed=true}}"  }
es01      | {"type": "server", "timestamp": "2019-09-09T21:21:52,534+0000", "level": "INFO", "component": "o.e.x.s.a.TokenService", "cluster.name": "docker-cluster", "node.name": "es01",  "message": "refresh keys"  }
es01      | {"type": "server", "timestamp": "2019-09-09T21:21:52,691+0000", "level": "INFO", "component": "o.e.x.s.a.TokenService", "cluster.name": "docker-cluster", "node.name": "es01",  "message": "refreshed keys"  }
es01      | {"type": "server", "timestamp": "2019-09-09T21:21:52,714+0000", "level": "INFO", "component": "o.e.l.LicenseService", "cluster.name": "docker-cluster", "node.name": "es01",  "message": "license [f4d0e140-9893-44ba-934c-374c3d44cab7] mode [basic] - valid"  }
es01      | {"type": "server", "timestamp": "2019-09-09T21:21:52,715+0000", "level": "INFO", "component": "o.e.x.s.s.SecurityStatusChangeListener", "cluster.name": "docker-cluster", "node.name": "es01",  "message": "Active license is now [BASIC]; Security is disabled"  }
es02      | {"type": "server", "timestamp": "2019-09-09T21:21:52,729+0000", "level": "INFO", "component": "o.e.c.s.ClusterApplierService", "cluster.name": "docker-cluster", "node.name": "es02", "cluster.uuid": "CtSsaGMfTJilsfwhbVT0LA", "node.id": "iwjzTfguR_-HPcagQpb7gA",  "message": "added {{es01}{CALxAOTnTv2Rkmk9DO4evA}{x4UK3E7fRUqMzBjHhNVxMQ}{172.18.0.3}{172.18.0.3:9300}{dim}{ml.machine_memory=2095673344, ml.max_open_jobs=20, xpack.installed=true},}, term: 5, version: 26, reason: Publication{term=5, version=26}"  }
es01      | {"type": "server", "timestamp": "2019-09-09T21:21:52,816+0000", "level": "INFO", "component": "o.e.h.AbstractHttpServerTransport", "cluster.name": "docker-cluster", "node.name": "es01", "cluster.uuid": "CtSsaGMfTJilsfwhbVT0LA", "node.id": "CALxAOTnTv2Rkmk9DO4evA",  "message": "publish_address {172.18.0.3:9200}, bound_addresses {0.0.0.0:9200}"  }
es01      | {"type": "server", "timestamp": "2019-09-09T21:21:52,817+0000", "level": "INFO", "component": "o.e.n.Node", "cluster.name": "docker-cluster", "node.name": "es01", "cluster.uuid": "CtSsaGMfTJilsfwhbVT0LA", "node.id": "CALxAOTnTv2Rkmk9DO4evA",  "message": "started"  }

kibana will output a prepend thing for us, and then JSON, so we need to remove the prepended text from the beginning of the line, before JSON.parse is called on the line.