MCPcopy Index your code
hub / github.com/cloudflare/octopus

github.com/cloudflare/octopus @v0.2.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.2.2 ↗ · + Follow
448 symbols 770 edges 51 files 82 documented · 18%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Octopus

The Octopus is part of our network automation pipeline. Its job is to aggregate data from different authoritative data sources into one Enriched Topology to provide a full picture to downstream systems.

The enriched topology is a graph of the entire network including all devices as well as connections like cables, circuits, etc. The nodes of the graph represent the devices -- routers, switches, optical equipment, servers, etc. -- including their meta data like status, device type, platform, role, and any custom fields or tags applied in NetBox for example. The edges within the graph are direct cables (DACs, copper/fiber patches), cable paths (e.g. through patch panels or optical equipment), circuits (e.g. dark fibers, wawe lengths, transports, etc.), or even could be serial connections.

Connectors

Each connector (think tentacle) of the Octopus taps into one of our data sources and consumes the bits we are interested in. It is responsible for querying the data, caching it locally, and updating the data in an interval meaningful for the data source and obtaining useful triggers, if any.

Topology generation

The Octopus holds the global Topology.

To gather data from all Connectors it will pass a pointer to a (single) new Topology object into each Connector, which will add its insight into relevant parts of the Topology. If devices, interfaces of devices, or other attributes are missing in the Topology, it is the Connectors responsible to add them.

Open questions

Should we just regenerate the Topology on every run (time based, trigger based, or both?) or should each Connector know (and therefore have the responsibility to figure out) if it has new data since the last run, so the Octopus can query all Connectors and the Topology only needs to be updates if at least one Connector has need data?

Observability

The Octopus exposes a number of metrics via an HTTP endpoint ready to be scraped by Prometheus.

  • octopus_topology_update_duration - Time it took to build the topology (milliseconds)
  • octopus_topology_build_time - Timestamp (epoch) when the current topology was build
  • octopus_topology_item_count - The number of instances per item (broken out bylabel item_type)
  • octopus_connector_health - Connector health indicatior (0/1) (broken out bylabel connector)
  • octopus_connector_load_duraton - Timestamp (epoch) when the current connector data was fetched (broken out by label connector)
  • octopus_connector_load_time - Time it took to fetch data (milliseconds) (broken out by label connector)
  • octopus_connector_update_error_count - The number of time the refresh of connector data has failed (broken out by label connector)

Other than those, Octopus is exposing gRPC-related metrics that comes from go-grpc-middleware.

Querying data

The Octopus exposes a gRPC API to query the enriched topology data.

You can manually query the enriched topology using grpcurl from the gRPC endpoint. Be aware that you need to increase the message size if the topology is larger than the default of 4MB. A call could look like this, querying the bond0 interface if ccr01.pad01

grpcurl -max-msg-sz=100000000 octopus-production.example.com:443 cloudflare.net.octopus.OctopusService.GetTopology | jq '.topology.devices[] | select(.name=="ccr01.pad01") | .interfaces[] | select(.name=="bond0")'

Extension points exported contracts — how you extend this code

Connector (Interface)
The Connector (think Tentacle of the Octopus) is the glue between any given data source and the Octopus. It is responsib [1 …
pkg/connector/connector.go
NetboxClientI (Interface)
(no doc) [1 implementers]
pkg/connector/netbox/netbox.go

Core symbols most depended-on inside this repo

NewMetaData
called by 31
pkg/model/metadata.go
NewVLANTag
called by 17
pkg/model/interface.go
ToProto
called by 17
pkg/model/ip.go
NewIP
called by 16
pkg/model/ip.go
GetName
called by 9
pkg/connector/connector.go
String
called by 6
pkg/model/cable.go
NewDevice
called by 4
pkg/model/device.go
newInterface
called by 4
pkg/model/interface.go

Shape

Method 313
Struct 66
Function 63
Interface 5
TypeAlias 1

Languages

Go100%

Modules by API surface

proto/octopus/octopus.pb.go192 symbols
pkg/connector/netbox/netbox.go41 symbols
pkg/connector/netbox/database.go22 symbols
proto/octopus/octopus_grpc.pb.go18 symbols
pkg/connector/netbox/netbox_client.go16 symbols
pkg/model/topology.go14 symbols
pkg/model/interface.go10 symbols
pkg/octopus/octopus.go9 symbols
pkg/model/location.go9 symbols
pkg/connector/connector.go9 symbols
pkg/connector/netbox/utils/utils.go8 symbols
pkg/octopus/prom_adapter.go5 symbols

For agents

$ claude mcp add octopus \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact