Metadata Enrichment (Addresses) API

Introduction to the API

NetObserv Flow and NetObserv SNMP provide an API for managing user-defined metadata (UDM) entries. See docs for this feature in NetObserv Flow and NetObserv SNMP. The API allows for creating, reading, updating, and deleting user-defined metadata entries (UDM entries).

The API documented here can be accessed via REST, gRPC, or connectrpc.

Configuring the API

To enable this API, set the following configuration values:

  • EF_PROCESSOR_ENRICH_IPADDR_METADATA_ENABLE: true

  • EF_PROCESSOR_ENRICH_IPADDR_METADATA_API_ENABLE: true

  • EF_PROCESSOR_ENRICH_IPADDR_METADATA_USERDEF_PATH: /etc/elastiflow/metadata/ipaddrs.yml

    • this setting can be configured to any location. The only requirement is that it is set to something.

See additional configuration documentation for NetObserv Flow or NetObserv SNMP

API Common Configuration

This API adheres to the same common config that our other APIs use. This includes:

  • optionally configuring basic auth to be required

  • optionally configuring TLS

  • optionally configuring a different port

See API Reference Overview for more details of what you can configure.

API Context

API Replaces YAML File Usage

Using this API will replace manually updating the UDM YAML file.

When you use this API, it will update the YAML file to represent latest state. In exchange, the product will not notice any updates to the YAML file, nor will it re-read that file.

Using any of the create or update calls (e.g. CreateUdm) will delete all comments in the YAML file, and probably change the order of stanzas in the file. The resulting file will be just the data in the file, not the comments or other formatting. So if you plan to make updates via the API, make sure there's no important information in the comments.

API Concurrency and Error Response

All RPCs are safe to call concurrently. The "read" RPCs will not block normal functioning of the collector, but the "write" RPCs will (very briefly), while the database is being updated and saved to disk.

Write operations are atomic and include updating the YAML file. If a write operation fails for any reason (returns an error), then neither the internal database nor the external YAML file were updated.

Keys are given as strings and parsed as IP addresses, CIDRs (IP prefixes), or IP ranges (a "from" IP and a "to" IP). In the API, if any key cannot be parsed, the operation will abort and return an error listing the problematic key.

Warning about Caching

NetObserv will cache any UDM entries in memory. Even if you make modifications via this API, it will not take immediatetly take effect because of caching. The default length for this cache is two hours.

API Methods

CountUdms POST /api/v1/enrich/ipaddr/udm.v1.UdmService/CountUdms

Return the number of items in the DB.

chevron-rightThe below examples assume you start with this set of UDM entries:hashtag

Example

Output

ListUdms POST /api/v1/enrich/ipaddr/udm.v1.UdmService/ListUdms

Return the records matching the given key. Non-string metadata values (e.g., numbers) are returned as strings.

Detailed Logic

If no key is given, it returns the entire DB.

If exact option is true, the key is matched exactly.

If exact option is false, all DB entries matching the requested key are returned, using the following rules:

  • key is a key as listed in the ipaddrs.yml file

    If key is not specified, then exact is ignored and all Udms will be returned.

  • If the key is:

    • An IP address

      • That IP will be returned if it exists.

      • Any CIDR that contains the given IP will be returned.

      • Any Range that contains the given IP will be returned.

    • A CIDR

      • Any IP within the given CIDR will be returned.

      • Any CIDR within the given CIDR will be returned.

      • Any Range within the given CIDR will be returned. That is, if the first and last IP in the range is in the given CIDR.

    • A Range

      • Any IP within the given Range will be returned.

      • Any CIDR within the given Range will be returned. That is, the first and last IP in the CIDR are in the given Range. E.g., the first and last IPs in 192.168.1.0/24 are 192.168.1.0 and 192.168.1.255.

      • Any Range within the given Range will be returned. That is, for a given range R1, a range R2 in the database will be returned if R1.From <= R2.From AND R2.To <= R1.To.

As mentioned above, ListUdms is safe to call concurrently; if you have multiple keys to query, you can safely call ListUdms concurrently for each key.

chevron-rightThe below examples assume you start with this set of UDM entries:hashtag

Example: List all UDM Entries

Output

Example: Search UDM Entries

Output

ListUdmKeys POST /api/v1/enrich/ipaddr/udm.v1.UdmService/ListUdmKeys

Return keys matching the given key. This API is logically equivalent to calling ListUdms on the given key, and then returning only the keys of the returned Udms. If no key is given, returns all keys.

The rules for searching work the same as ListUdm Methodarrow-up-right

chevron-rightThe below examples assume you start with this set of UDM entries:hashtag

List All Keys

Output

List a specific key

Output

List all keys matching a given key

Output

CreateUdm POST /api/v1/enrich/ipaddr/udm.v1.UdmService/CreateUdm

Create a new UDM entry. Return an error if the given key already exists.

Output

BatchCreateUdms POST /api/v1/enrich/ipaddr/udm.v1.UdmService/BatchCreateUdms

Create the given set of Udms and return them. Return an error if any of the given Udms already exist.

Creates are atomic, and include saving the updates to the yml file.

Output

The status of the DB after running the above example commands:

DeleteUdm POST /api/v1/enrich/ipaddr/udm.v1.UdmService/DeleteUdm

Deletes the given Udm; the key must match exactly

Deletes are atomic and include updating the yml file.

Example

Output

Result

UpdateUdm POST /api/v1/enrich/ipaddr/udm.v1.UdmService/UpdateUdm

Update the given Udm with the given data. The UpdateMask field inside the request specifies which fields to update. If the UpdateMask is empty, all fields are updated, including those that were not specified in the update call (which will be set to their "zero value"). (See the example below for more details.)

Return the updated Udm or an error if the given key does not exist.

Example: Without an update_mask

Assuming this starting content

Output

This command didn't give an update_mask, so all the fields not specified in the udm object were cleared.

With an update_mask

assuming

Output

This command did give an update_mask, so only the vlan and tags fields were updated.

BatchUpdateUdms POST /api/v1/enrich/ipaddr/udm.v1.UdmService/BatchUpdateUdms

Update the given Udms with the given data. The UpdateMask field inside the request specifies which fields to update. If UpdateMask is empty, all fields are updated, including those that were not specified in the update call (which will be set to their "zero value"). (See the example below for more details.)

Return the updated Udms or an error if any of the given keys do not exist.

Updates are atomic and include saving the updates to the yml file.

Implementation note: BatchUpdateUdms accepts a single BatchUpdatUdmsRequest struct containing a slice of UpdateUdmRequest structs, and a single UpdateMask field, which is used for the entire batch of updates. Each UpdateUdmRequest struct also has its own UpdateMask, which is ignored.

Without an update_mask

Output

As above, since no update_mask was specified, all fields not mentioned were cleared.

With an update_mask

  • Update only the tags and metadata fields.

  • Even though vlan is listed in the first UDM entry, it is not updated.

  • Even though name is listed in both UDMs, it is not updated.

  • Only the top-level update_mask field is valid. Even though the first request says "update_mask":"name", this is ignored.

Output

note

In a BatchUpdateUdms request, only the top-level update_mask field is used; the update_mask field in each request object is ignored.

GRPC Interface Details

We expose all the exact same methods via gRPC in addition to HTTP/REST. The gRPC protocolarrow-up-right is a different protocol than HTTP/REST. You do not need to use the gRPC interface if you do not want to.

For those that are interested, below are some additional details regarding the gRPC interface to this API.

Inspecting the Schema With grpcurl

You can use grpcurl command to inspect and navigate the grpc schema.

See the grpcurl documentationarrow-up-right for more details on using the gRPC reflection API.

Proto file

Last updated

Was this helpful?