Skip to main content

controller.go

controller.go - Overview

  1. Overview The controller.go file defines the LogParsingPipelineController which manages the lifecycle of log parsing pipelines. This includes storing, validating, applying, and retrieving pipelines, as well as generating collector configurations. It interacts with a repository for data access and an agent configuration manager.

  2. Detailed Documentation

LogParsingPipelineController

  • Purpose: Manages the deployment cycle of log parsing pipelines.
  • Fields:
    • Repo: An interface for accessing and managing pipelines in the data store.
    • GetIntegrationPipelines: A function to retrieve integration pipelines.
  • Methods:
    • ApplyPipelines: Stores new or changed pipelines and initiates a new configuration update.
    • ValidatePipelines: Validates the format and configuration of pipelines.
    • getEffectivePipelinesByVersion: Returns the effective list of pipelines for a given version, combining user-defined pipelines with integration pipelines.
    • GetPipelinesByVersion: Retrieves pipelines and configuration version information.
    • PreviewLogsPipelines: Simulates the processing of logs through the provided pipelines and returns the processed logs and collector logs.
    • AgentFeatureType: Returns the agent feature type.
    • RecommendAgentConfig: Recommends an agent configuration based on the current configuration and pipelines.

NewLogParsingPipelinesController

  • Purpose: Creates a new instance of LogParsingPipelineController.
  • Parameters:
    • sqlStore (sqlstore.SQLStore): The SQL store implementation.
    • getIntegrationPipelines (func(context.Context) ([]pipelinetypes.GettablePipeline, *model.ApiError)): A function to retrieve integration pipelines.
  • Returns:
    • *LogParsingPipelineController: A pointer to the new controller instance.
    • error: An error, if any.

PipelinesResponse

  • Purpose: Represents the HTTP response for pipeline configuration requests.
  • Fields:
    • ConfigVersion (*agentConf.ConfigVersion): The configuration version information.
    • Pipelines ([]pipelinetypes.GettablePipeline): A slice of pipelines.
    • History ([]agentConf.ConfigVersion): A slice of configuration version history.

ApplyPipelines

  • Purpose: Stores new or changed pipelines and initiates a new config update.
  • Parameters:
    • ctx (context.Context): The context.
    • orgID (string): The organization ID.
    • postable ([]pipelinetypes.PostablePipeline): A slice of postable pipelines.
  • Returns:
    • *PipelinesResponse: The pipelines response.
    • *model.ApiError: An API error, if any.

ValidatePipelines

  • Purpose: Validates the format and configuration of pipelines.
  • Parameters:
    • ctx (context.Context): The context.
    • postedPipelines ([]pipelinetypes.PostablePipeline): A slice of posted pipelines.
  • Returns:
    • *model.ApiError: An API error, if any.

getEffectivePipelinesByVersion

  • Purpose: Returns effective list of pipelines including user created pipelines and pipelines for installed integrations.
  • Parameters:
    • ctx (context.Context): The context.
    • version (int): The version of the pipelines to retrieve.
  • Returns:
    • []pipelinetypes.GettablePipeline: A slice of gettable pipelines.
    • *model.ApiError: An API error, if any.

GetPipelinesByVersion

  • Purpose: Responds with version info and associated pipelines
  • Parameters:
    • ctx (context.Context): The context.
    • version (int): The version of the pipelines to retrieve.
  • Returns:
    • *PipelinesResponse: The pipelines response.
    • *model.ApiError: An API error, if any.

PipelinesPreviewRequest

  • Purpose: Defines the request structure for previewing pipelines.
  • Fields:
    • Pipelines ([]pipelinetypes.GettablePipeline): The pipelines to preview.
    • Logs ([]model.SignozLog): The logs to use for preview.

PipelinesPreviewResponse

  • Purpose: Defines the response structure for previewing pipelines.
  • Fields:
    • OutputLogs ([]model.SignozLog): The processed logs.
    • CollectorLogs ([]string): Logs from the collector during processing.

PreviewLogsPipelines

  • Purpose: Simulates the processing of logs through the provided pipelines.
  • Parameters:
    • ctx (context.Context): The context.
    • request (*PipelinesPreviewRequest): The preview request.
  • Returns:
    • *PipelinesPreviewResponse: The preview response.
    • *model.ApiError: An API error, if any.

AgentFeatureType

  • Purpose: Returns the agent feature type.
  • Parameters:
    • pc (*LogParsingPipelineController): The LogParsingPipelineController instance.
  • Returns:
    • agentConf.AgentFeatureType: The agent feature type (LogPipelinesFeatureType).

RecommendAgentConfig

  • Purpose: Recommends an agent configuration based on the current configuration and pipelines.
  • Parameters:
    • currentConfYaml ([]byte): The current agent configuration in YAML format.
    • configVersion (*agentConf.ConfigVersion): The configuration version.
  • Returns:
    • recommendedConfYaml ([]byte): The recommended agent configuration in YAML format.
    • serializedSettingsUsed (string): The serialized pipeline data used to generate the configuration.
    • apiErr (*model.ApiError): An API error, if any.
  1. Code Examples N/A

  2. Clarity and Accuracy The documentation is based on the provided code and aims to be accurate and clear.

  3. Markdown & MDX Perfection The markdown syntax is correct.

  4. Edge Cases To Avoid Breaking MDX No MDX errors were detected.

  5. Getting Started Relevance Include in Getting Started: NO