{"id":21511497,"url":"https://github.com/netobserv/goflow2-loki-exporter","last_synced_at":"2025-04-09T18:08:50.017Z","repository":{"id":46533009,"uuid":"393362755","full_name":"netobserv/goflow2-loki-exporter","owner":"netobserv","description":"Loki exporter plugin for goflow2","archived":false,"fork":false,"pushed_at":"2021-10-18T07:57:11.000Z","size":3558,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-23T20:06:08.285Z","etag":null,"topics":["kubernetes","loki","netflow"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/netobserv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-08-06T11:57:13.000Z","updated_at":"2024-12-06T04:33:02.000Z","dependencies_parsed_at":"2022-09-03T21:11:23.927Z","dependency_job_id":null,"html_url":"https://github.com/netobserv/goflow2-loki-exporter","commit_stats":null,"previous_names":["jotak/goflow2-loki-exporter"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netobserv%2Fgoflow2-loki-exporter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netobserv%2Fgoflow2-loki-exporter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netobserv%2Fgoflow2-loki-exporter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netobserv%2Fgoflow2-loki-exporter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/netobserv","download_url":"https://codeload.github.com/netobserv/goflow2-loki-exporter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248085164,"owners_count":21045135,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["kubernetes","loki","netflow"],"created_at":"2024-11-23T22:14:27.604Z","updated_at":"2025-04-09T18:08:49.989Z","avatar_url":"https://github.com/netobserv.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# goflow2-loki-exporter\n\nWIP\n\n## Description\n\nPush flows directly to loki. It is an alternative to sending flows to file/stdout and using promtail.\n\n## Configuration\n\n\n\n## Build image\n\n(This image will contain both goflow2 and the plugin)\n\n```bash\ndocker build --build-arg VERSION=`git describe --long HEAD` -t quay.io/jotak/goflow2:loki-latest .\ndocker push quay.io/jotak/goflow2:loki-latest\n\n# or\n\npodman build --build-arg VERSION=`git describe --long HEAD` -t quay.io/jotak/goflow2:loki-latest .\npodman push quay.io/jotak/goflow2:loki-latest\n\n# or with kube-enricher\n\npodman build --build-arg VERSION=`git describe --long HEAD` -t quay.io/jotak/goflow2:kube-loki-latest -f examples/with-kube-enricher.dockerfile .\npodman push quay.io/jotak/goflow2:kube-loki-latest\n```\n\nTo run it, simply `pipe` goflow2 output to `loki-exporter`.\n\n## Examples in kube\n\nAssuming built image is `quay.io/jotak/goflow2:loki-latest`.\n\nSince both goflow + exporter are contained inside a single image, you can declare the following command inside the pod container:\n\n```yaml\n# ...\n      containers:\n      - command:\n        - /bin/sh\n        - -c\n        - /goflow2 -loglevel \"trace\" | /loki-exporter -loglevel \"trace\"\n        image: quay.io/jotak/goflow2:loki-latest\n# ...\n```\n\nCheck the [examples](./examples) directory.\n\n### Run on Kind with ovn-kubernetes\n\nThis example includes the kube-enricher: https://github.com/jotak/goflow2-kube-enricher/\n\nFirst, [refer to this documentation](https://github.com/ovn-org/ovn-kubernetes/blob/master/docs/kind.md) to setup ovn-k on Kind.\nThen:\n\n```bash\nkubectl apply -f ./examples/goflow-kube-loki.yaml\nGF_IP=`kubectl get svc goflow -ojsonpath='{.spec.clusterIP}'` \u0026\u0026 echo $GF_IP\nkubectl set env daemonset/ovnkube-node -c ovnkube-node -n ovn-kubernetes OVN_IPFIX_TARGETS=\"$GF_IP:2055\"\n```\n\nFinally check goflow's logs for output\n\n#### Legacy Netflow (v5)\n\nSimilarly:\n\n```bash\nkubectl apply -f ./examples/goflow-kube-loki-nf5.yaml\nGF_IP=`kubectl get svc goflow-leg -ojsonpath='{.spec.clusterIP}'` \u0026\u0026 echo $GF_IP\nkubectl set env daemonset/ovnkube-node -c ovnkube-node -n ovn-kubernetes OVN_NETFLOW_TARGETS=\"$GF_IP:2056\"\n```\n\n\n### Run on OpenShift with OVNKubernetes network provider\n\nThis example includes the kube-enricher: https://github.com/jotak/goflow2-kube-enricher/\n\n- Pre-requisite: make sure you have a running OpenShift cluster (4.8 at least) with `OVNKubernetes` set as the network provider.\n\nIn OpenShift, a difference with the upstream `ovn-kubernetes` is that the flows export config is managed by the `ClusterNetworkOperator`.\n\n```bash\noc apply -f ./examples/goflow-kube-loki.yaml\nGF_IP=`oc get svc goflow -ojsonpath='{.spec.clusterIP}'` \u0026\u0026 echo $GF_IP\noc patch networks.operator.openshift.io cluster --type='json' -p \"$(sed -e \"s/GF_IP/$GF_IP/\" examples/net-cluster-patch.json)\"\n```\n\n### Loki quickstart (helm)\n\n```bash\nhelm upgrade --install loki grafana/loki-stack --set promtail.enabled=false\nhelm install loki-grafana grafana/grafana\nkubectl get secret loki-grafana -o jsonpath=\"{.data.admin-password}\" | base64 --decode ; echo\nkubectl port-forward svc/loki-grafana 3000:80\n```\n\nOpen http://localhost:3000/\nLogin with admin + printed password\nAdd datasource =\u003e Loki =\u003e\nhttp://loki:3100/\n\nExample of queries:\n\n- View raw logs:\n\n`{app=\"goflow2\"}`\n\n- Top 10 sources by volumetry (1 min-rate):\n\n`topk(10, (sum by(SrcWorkload,SrcNamespace) ( rate({ app=\"goflow2\" } | json | __error__=\"\" | unwrap Bytes [1m]) )))`\n\n- Top 10 destinations for a given source (1 min-rate):\n\n`topk(10, (sum by(DstWorkload,DstNamespace) ( rate({ app=\"goflow2\",SrcNamespace=\"default\",SrcWorkload=\"goflow\" } | json | __error__=\"\" | unwrap Bytes [1m]) )))`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetobserv%2Fgoflow2-loki-exporter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetobserv%2Fgoflow2-loki-exporter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetobserv%2Fgoflow2-loki-exporter/lists"}