Skip to content

Latest commit

 

History

History
428 lines (328 loc) · 19.4 KB

File metadata and controls

428 lines (328 loc) · 19.4 KB

Routes

Overview

Actions related to Routes

Available Operations

  • list - List all Routes
  • get - Get a Routing table
  • update - Update a Route
  • append - Add a Route to the end of the Routing table

list

Get a list of all Routes.

Example Usage

from cribl_control_plane import CriblControlPlane, models
import os


with CriblControlPlane(
    "https://api.example.com",
    security=models.Security(
        bearer_auth=os.getenv("CRIBLCONTROLPLANE_BEARER_AUTH", ""),
    ),
) as ccp_client:

    res = ccp_client.routes.list()

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.CountedRoutes

Errors

Error Type Status Code Content Type
errors.Error 500 application/json
errors.APIError 4XX, 5XX */*

get

Get the specified Routing table.

Example Usage

from cribl_control_plane import CriblControlPlane, models
import os


with CriblControlPlane(
    "https://api.example.com",
    security=models.Security(
        bearer_auth=os.getenv("CRIBLCONTROLPLANE_BEARER_AUTH", ""),
    ),
) as ccp_client:

    res = ccp_client.routes.get(id="<id>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
id str ✔️ The id of the Routing table to get. The supported value is default.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.CountedRoutes

Errors

Error Type Status Code Content Type
errors.Error 500 application/json
errors.APIError 4XX, 5XX */*

update

Update a Route in the specified Routing table.

\1 This endpoint does not support partial updates. Cribl removes any omitted fields when updating the Routing table.

Confirm that the configuration in your request body is correct before sending the request. If the configuration is incorrect, the updated Routing table might not function as expected.

Cribl also removes any omitted Routes when updating the Routing table.

Example Usage: RoutesUpdateExamplesBasicRoute

from cribl_control_plane import CriblControlPlane, models
import os


with CriblControlPlane(
    "https://api.example.com",
    security=models.Security(
        bearer_auth=os.getenv("CRIBLCONTROLPLANE_BEARER_AUTH", ""),
    ),
) as ccp_client:

    res = ccp_client.routes.update(id_param="<value>", id="default", routes=[
        {
            "description": "Route access logs to main Pipeline",
            "filter_": "source == \"access.log\"",
            "name": "my-route",
            "pipeline": "main",
            "final": True,
            "id": "default",
        },
    ])

    # Handle response
    print(res)

Example Usage: RoutesUpdateExamplesMultipleRoutes

from cribl_control_plane import CriblControlPlane, models
import os


with CriblControlPlane(
    "https://api.example.com",
    security=models.Security(
        bearer_auth=os.getenv("CRIBLCONTROLPLANE_BEARER_AUTH", ""),
    ),
) as ccp_client:

    res = ccp_client.routes.update(id_param="<value>", id="default", routes=[
        {
            "description": "Route speedtest logs",
            "filter_": "source == \"speedtest.log\"",
            "name": "speedtest",
            "output": "default",
            "pipeline": "main",
            "final": False,
            "id": "route-speedtest",
        },
        {
            "description": "Route mtr logs",
            "filter_": "source == \"mtr.log\"",
            "name": "mtr",
            "output": "default",
            "pipeline": "passthru",
            "final": False,
            "id": "route-mtr",
        },
        {
            "description": "Route statsd metrics",
            "filter_": "source == \"statsd.log\"",
            "name": "statsd",
            "output": "devnull",
            "pipeline": "prometheus_metrics",
            "final": False,
            "id": "route-statsd",
        },
        {
            "description": "Catch-all Route for all other events",
            "filter_": "true",
            "name": "default",
            "output": "default",
            "pipeline": "main",
            "final": True,
            "id": "route-default",
        },
    ])

    # Handle response
    print(res)

Example Usage: RoutesUpdateExamplesRouteWithDefaults

from cribl_control_plane import CriblControlPlane, models
import os


with CriblControlPlane(
    "https://api.example.com",
    security=models.Security(
        bearer_auth=os.getenv("CRIBLCONTROLPLANE_BEARER_AUTH", ""),
    ),
) as ccp_client:

    res = ccp_client.routes.update(id_param="<value>", id="default", routes=[
        {
            "description": "Route access logs to main Pipeline",
            "filter_": "source == \"access.log\"",
            "name": "my-route",
            "pipeline": "main",
        },
    ])

    # Handle response
    print(res)

Example Usage: RoutesUpdateExamplesRouteWithOutputExpression

from cribl_control_plane import CriblControlPlane, models
import os


with CriblControlPlane(
    "https://api.example.com",
    security=models.Security(
        bearer_auth=os.getenv("CRIBLCONTROLPLANE_BEARER_AUTH", ""),
    ),
) as ccp_client:

    res = ccp_client.routes.update(id_param="<value>", id="default", routes=[
        {
            "description": "Route with dynamic Destination based on environment",
            "enable_output_expression": True,
            "filter_": "source == \"dynamic.log\"",
            "name": "dynamic-output",
            "output_expression": "`myDest_${C.logStreamEnv}`",
            "pipeline": "main",
            "final": True,
            "id": "route-dynamic",
        },
    ])

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
id_param str ✔️ The id of the Routing table that contains the Route to update. The supported value is default.
id str ✔️ Unique identifier for the Routing table. The supported value is default.
routes List[models.RouteConfInput] ✔️ Array of Route configurations that define how events are processed and routed.
comments List[models.RouteComment] Array of user-provided comments that describe or annotate Routes.
groups Dict[str, models.AdditionalPropertiesTypeRoutesGroups] Information about the Route Groups that the Route is associated with.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.CountedRoutes

Errors

Error Type Status Code Content Type
errors.Error 500 application/json
errors.APIError 4XX, 5XX */*

append

Add a Route to the end of the specified Routing table.

Example Usage: RoutesAppendExamplesMultipleRoutes

from cribl_control_plane import CriblControlPlane, models
import os


with CriblControlPlane(
    "https://api.example.com",
    security=models.Security(
        bearer_auth=os.getenv("CRIBLCONTROLPLANE_BEARER_AUTH", ""),
    ),
) as ccp_client:

    res = ccp_client.routes.append(id="<id>", request_body=[
        {
            "description": "Route audit logs",
            "filter_": "source == \"audit.log\"",
            "name": "audit",
            "output": "default",
            "pipeline": "main",
            "final": False,
            "id": "route-audit",
        },
        {
            "description": "Route security logs",
            "filter_": "source == \"security.log\"",
            "name": "security",
            "output": "devnull",
            "pipeline": "passthru",
            "final": False,
            "id": "route-security",
        },
    ])

    # Handle response
    print(res)

Example Usage: RoutesAppendExamplesRouteWithDefaults

from cribl_control_plane import CriblControlPlane, models
import os


with CriblControlPlane(
    "https://api.example.com",
    security=models.Security(
        bearer_auth=os.getenv("CRIBLCONTROLPLANE_BEARER_AUTH", ""),
    ),
) as ccp_client:

    res = ccp_client.routes.append(id="<id>", request_body=[
        {
            "description": "Route with server-generated id and default final value",
            "filter_": "source == \"new.log\"",
            "name": "new-route",
            "pipeline": "main",
        },
    ])

    # Handle response
    print(res)

Example Usage: RoutesAppendExamplesRouteWithOutputExpression

from cribl_control_plane import CriblControlPlane, models
import os


with CriblControlPlane(
    "https://api.example.com",
    security=models.Security(
        bearer_auth=os.getenv("CRIBLCONTROLPLANE_BEARER_AUTH", ""),
    ),
) as ccp_client:

    res = ccp_client.routes.append(id="<id>", request_body=[
        {
            "description": "Route with dynamic Destination based on environment",
            "enable_output_expression": True,
            "filter_": "source == \"dynamic.log\"",
            "name": "dynamic-append",
            "output_expression": "`myDest_${C.logStreamEnv}`",
            "pipeline": "main",
            "final": True,
            "id": "route-dynamic-append",
        },
    ])

    # Handle response
    print(res)

Example Usage: RoutesAppendExamplesSingleRoute

from cribl_control_plane import CriblControlPlane, models
import os


with CriblControlPlane(
    "https://api.example.com",
    security=models.Security(
        bearer_auth=os.getenv("CRIBLCONTROLPLANE_BEARER_AUTH", ""),
    ),
) as ccp_client:

    res = ccp_client.routes.append(id="<id>", request_body=[
        {
            "description": "Route new logs to main pipeline",
            "filter_": "source == \"new.log\"",
            "name": "new-route",
            "pipeline": "main",
            "final": True,
            "id": "route-new",
        },
    ])

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
id str ✔️ The id of the Routing table to add the Route to. The supported value is default.
request_body List[models.RouteConfInput] ✔️ RouteDefinitions object.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.CountedRoutes

Errors

Error Type Status Code Content Type
errors.Error 500 application/json
errors.APIError 4XX, 5XX */*