# K6Resource

- Module: [CommunityToolkit.Aspire.Hosting.k6](/reference/api/typescript/communitytoolkit.aspire.hosting.k6.md)
- Version: `13.4.0`
- Kind: `handle`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire)

A resource that represents a Grafana k6 instance

## Definition

```typescript
interface K6Resource
  extends IComputeResource,
    IResource,
    IResourceWithArgs,
    IResourceWithEndpoints,
    IResourceWithEnvironment,
    IResourceWithProbes,
    IResourceWithWaitSupport {
  readonly primaryEndpoint: EndpointReference;
  withK6OtlpEnvironment(): K6Resource;
  withScript(
      scriptPath: string,
      virtualUsers?: number,
      duration?: string): K6Resource;
}
```

## Properties

- `primaryEndpoint`: `EndpointReference` `get` -- Gets the primary endpoint for the Grafana k6 instance. This endpoint is used for all API calls over HTTP.

## Methods

- [withK6OtlpEnvironment](/reference/api/typescript/communitytoolkit.aspire.hosting.k6/k6resource/withk6otlpenvironment.md) -- `method` -- Set K6 environment variables from the existing OTEL environment set for this resource. See https://grafana.com/docs/k6/latest/results-output/real-time/opentelemetry/#configuration.
    ```typescript
  withK6OtlpEnvironment(): K6Resource
  ```
- [withScript](/reference/api/typescript/communitytoolkit.aspire.hosting.k6/k6resource/withscript.md) -- `method` -- Runs a k6 JS script when starting the Grafana k6 container resource.
    ```typescript
  withScript(scriptPath: string, virtualUsers?: number, duration?: string): K6Resource
  ```
