LogoLogo
HomeBlogGet a Demo
  • Introduction
  • Install Lunar
  • Learn the basics
  • 📖Docs
    • Key concepts
    • Component JSON
    • Catalog JSON
    • Lunar CLI Reference
  • 📝Configuration
    • lunar-config.yml
      • catalogers
      • catalogers/hooks
      • domains
      • components
      • collectors
      • collectors/hooks
      • policies
    • lunar.yml
  • 🛠️Plugin SDKs
    • Plugins configuration
      • lunar-cataloger.yml
      • lunar-collector.yml
      • lunar-policy.yml
    • Bash SDK
      • Cataloger
      • Collector
    • Python SDK
      • Collector
      • Policy
        • Check
        • Path
        • ComponentData
        • NoDataError
        • Utility Functions
  • ⚙️SQL API
    • Overview
    • Views
      • domains
      • components
      • component_deltas
      • initiatives
      • policies
      • checks
      • prs
      • catalog
Powered by GitBook

©️ Earthly Technologies

On this page
  • Collectors
  • Collector
  1. Configuration
  2. lunar-config.yml

collectors

Collectors

  • lunar-config.yml -> collectors

  • Type: array

  • Form:

    collectors:
      - <collector-object>
      - <collector-object>
      - ...

Collectors are used to collect live information from various sources to associate with individual components.

Example collectors definition:

collectors:
  - uses: github://third-party/some-collector@v1
    on: [auth, frontend]
    hook:
      type: ci-before-command
      pattern: ^go build.*
  - uses: ./my-collector
    on: ["domain:my-domain"]
    hook:
      type: ci-before-job
      pattern: .*
  - uses: ./my-collector
    on: ["domain:foo-product"]
    hook:
      type: code
  - uses: ./another-collector
    on: [go]
    hook:
      type: cron
      schedule: "0 2 * * *"
  - name: Hello world collector
    runBash: lunar collect hello world
    on: [java]
    hook: 
      type: ci-after-command
      pattern: ^mvn install.*
  - name: Example script collector
    mainBash: ./my-script.sh
    on: [python]
    hook:
      type: cron
      schedule: "0 2 * * *"

Collector

  • lunar-config.yml -> collectors.<collector-index>

  • Type: object

  • Forms

    • Uses form (use an external collector plugin):

      name: <collector-name>
      uses: <collector-string>
      with:
        <input-name>: <input-value>
        ...
      on: <domain-array>
    • Run form (define a collector inline):

      name: <collector-name>
      run<language>: <command-string>
      on: <domain-array>
      hook: <hook-configuration>
      hooks:
        - <hook-configuration>
        - <hook-configuration>
        - ...
    • Main form (define a collector inline with a main file):

      name: <collector-name>
      main<language>: <main-file-path>
      on: <domain-array>
      hook: <hook-configuration>
      hooks:
        - <hook-configuration>
        - <hook-configuration>
        - ...

Collectors are used to collect live information from various sources to associate with individual components. Collectors can be used to instrument CI/CD pipelines, run cron jobs, or execute arbitrary logic when code changes.

Collectors can either be imported (Uses form), defined as an inline command (Run form), or defined as a script to run (Main form). When a collector is defined inline (Run and Main forms), a hook must be specified to determine when the collector should run.

name

  • lunar-config.yml -> collectors.<collector-index>.name

  • Type: string

  • Required for Run and Main collector forms, Optional for Uses collector form

The name field is used to specify the name of the collector. If a name is not provided in the case of a collector plugin, the name from the collector plugin is used. The name must be unique within the configuration.

uses

  • lunar-config.yml -> collectors.<collector-index>.uses

  • Type: string

  • Forms

    • GitHub form: github://<org>/<repo>@<version>

    • Local form: ./<path-to-collector>

  • Required in Uses collector form

The uses field specifies an external (plugin) collector to use. The collector can be a third-party collector, or a local collector defined in a subdirectory.

with

  • lunar-config.yml -> collectors.<collector-index>.with

  • Type: object

  • Optional

The with field specifies the inputs to pass to the collector plugin. The inputs are defined in the collector's configuration file.

run<language>

  • lunar-config.yml -> collectors.<collector-index>.run<language>

  • Type: string

  • Required in Run collector form

Defines the command to execute when the collector is invoked. Only Bash and Python are supported. So runBash and runPython are the only valid fields.

If an install.sh file is present in the same directory as lunar-config.yml or lunar-collector.yml, Lunar will run the install script before running the collector script. This script is executed only once in each environment. In ephemeral environments, the script is executed every time the environment is created (e.g. on each CI job, or on each code collector execution). Lunar uses a lock file under the hood to detect if the script has previously been executed.

runBash

  • lunar-config.yml -> collectors.<collector-index>.runBash

  • Type: string

The runBash field specifies the bash collector script to run.

runPython

  • lunar-config.yml -> collectors.<collector-index>.runPython

  • Type: string

The runPython field specifies the python collector script to run.

If a requirements.txt file is present in the same directory as lunar-config.yml or lunar-collector.yml, Lunar will install the dependencies before running the collector script.

main<language>

  • lunar-config.yml -> collectors.<collector-index>.main<language>

  • Type: string

  • Required in Main collector form

Defines the main file path used to execute when the collector is invoked. Only Bash and Python are supported. So mainBash and mainPython are the only valid field.

The file path is relative to the root of the Lunar configuration repository. In the case of an external plugin definition, the path is relative to the plugin directory.

If an install.sh file is present in the same directory as lunar-config.yml or lunar-collector.yml, Lunar will run the install script before running the collector script. This script is executed only once in each environment. In ephemeral environments, the script is executed every time the environment is created (e.g. on each CI job, or on each code collector execution). Lunar uses a lock file under the hood to detect if the script has previously been executed.

mainBash

  • lunar-config.yml -> collectors.<collector-index>.mainBash

  • Type: string

The mainBash field specifies the path to the bash main file to run.

mainPython

  • lunar-config.yml -> collectors.<collector-index>.mainPython

  • Type: string

The mainPython field specifies the path to the python main file to run.

If a requirements.txt file is present in the same directory as lunar-config.yml or lunar-collector.yml, Lunar will install the dependencies before running the collector script.

on

  • lunar-config.yml -> collectors.<collector-index>.on

  • Type: array

  • Required

The on field specifies the tags that the collector should be associated with. The collector will only run when the component has one or more of the specified tags.

To associate the collector with a domain, use the tag domain:<domain-name>. For example, to associate a collector with the domain bar, which is under the domain foo, use the tag domain:foo.bar.

hook

  • lunar-config.yml -> collectors.<collector-index>.hook

  • Type: object

  • One of hook or hooks is required in Run collector form

Using hook is equivalent to using a single hook in the hooks field. The hook field specifies when the collector should run.

hooks

  • lunar-config.yml -> collectors.<collector-index>.hooks

  • Type: array

  • One of hook or hooks is required in Run collector form

The hooks field specifies when the collector should run.

PreviouscomponentsNextcollectors/hooks

Last updated 15 days ago

For more information about hook definitions see the .

For more information about hook definitions see the .

📝
hooks configuration page
hooks configuration page