---
layout: docs
page_title: Target Plugins
description: Learn how to author a Nomad Autoscaler Target plugin.
---

# Target Plugins

Target plugins are used by the autoscaler to retrieve information about a
scaling target and also to perform a scaling action against them.

For a real-world example of a Nomad Target plugin implementation, see the
[Nomad `group->count` plugin][nomad_group_count_plugin].

## Authoring Target Plugins

Authoring a target plugin in Go can be accomplished by implementing the
[`target.Target`][target_plugin] interface, alongside a `main` package to
launch the plugin.

The [`no-op` Target plugin][noop_plugin] can be used as a starting point for new Target
plugins.

## Target Plugin API

The [base plugin][base_plugin] interface must be implemented in addition to the
following functions.

#### `Scale(action sdk.ScalingAction, config map[string]string) error`

The `Scale` method is called by the agent during policy evaluation. The `action`
argument specifies the [details][scaling_action_sdk] about the scaling action
that should be made against the target. `config` includes the details about the
scaling target that were provided in the [scaling policy][policy_target].

#### `Status(config map[string]string) (*sdk.TargetStatus, error)`

The `Status` method is called by the agent in order to determine the current
status of a scaling target. This is performed as part of policy evaluation,
and the [information][target_status_sdk] returned may be used by the scaling
strategy to inform the next scaling action. Information returned includes
current scaling level, readiness, and arbitrary metadata.

[nomad_group_count_plugin]: https://github.com/hashicorp/nomad-autoscaler/tree/v0.3.0/plugins/builtin/target/nomad
[target_plugin]: https://github.com/hashicorp/nomad-autoscaler/blob/v0.3.0/plugins/target/target.go#L12
[base_plugin]: /nomad/tools/autoscaling/internals/plugins/base
[noop_plugin]: https://github.com/hashicorp/nomad-autoscaler/tree/v0.3.0/plugins/test/noop-target
[scaling_action_sdk]: https://github.com/hashicorp/nomad-autoscaler/blob/v0.3.0/sdk/strategy.go#L25
[policy_target]: /nomad/tools/autoscaling/policy#target
[target_status_sdk]: https://github.com/hashicorp/nomad-autoscaler/blob/v0.3.0/sdk/target.go#L6
