8000 4380 - Inference logging to blob storage by cjohannsen-cloudera · Pull Request #4473 · kserve/kserve · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

4380 - Inference logging to blob storage #4473

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

cjohannsen-cloudera
Copy link
@cjohannsen-cloudera cjohannsen-cloudera commented May 14, 2025

What this PR does / why we need it:
This adds support for storing model request and response logs to S3. The implementation is generic enough that adding support for GCS et al will be straightforward, I hope.

Storage is defined using the StorageSpec. The existing v1beta1.StorageSpec has been refactored to extract a base struct.

// StorageSpec defines a spec for an object in an object store
type StorageSpec struct {
	// The path to the object in the storage. Note that this path is relative to the storage URI.
	// +optional
	Path *string `json:"path,omitempty"`
	// Parameters to override the default storage credentials and config.
	// +optional
	Parameters *map[string]string `json:"parameters,omitempty"`
	// The Storage Key in the secret for this object.
	// +optional
	StorageKey *string `json:"key,omitempty"`
}

The existing StorageSpec is now ModelStorageSpec and adds the SchemaPath

type ModelStorageSpec struct {
	StorageSpec `json:",inline"`
	// The path to the model schema file in the storage.
	// +optional
	SchemaPath *string `json:"schemaPath,omitempty"`
}

This is a pure refactor.

The LoggerConfig now contains a StorageSpec that defines the logger storage output location and a service account name used to fetch credentials.

  logger: |-
    {
        "image" : "kserve/agent:latest",
        "memoryRequest": "100Mi",
        "memoryLimit": "1Gi",
        "cpuRequest": "100m",
        "cpuLimit": "1",
        "defaultUrl": "http://default-broker",
        "storage": {
            "path": "",
            "parameters": {
              "type": "s3",
              "format": "json" 
            },
            "key": ""
            "serviceAccountName": "",
        }
    }

Three new command line parameters have been added to the agent to allow the storage configuration to be passed in when injecting the agent.

--log-store-path [path] - path within the storage location to write the logger output
--log-store-format - output format of the stored data, one of "json" or "yaml", default "json"

By default the logger service account is undefined, and the logger storage feature is disabled.

If the service account name is defined, the logger will attempt to look for a Service Account with the matching name and mount the secrets it contains. When the agent is launched the secrets are available in the environment.

When an inference occurs the S3 client is constructed and the request and response are stored to the blob store path specified above. The agent uses the existing client defined for the model downloader to simplify integration and configuration, enhanced to allow for uploads.

Which issue(s) this PR fixes

Fixes #4380

Type of changes

  • New feature (non-breaking change which adds functionality)

Feature/Issue validation/testing:

[x] Added additional test to logger/handler_test.go
[x] Added new test, logger/store_test.go
[x] Added new agent command argument to agent_injector_test.go

To test locally create a secret in the default namespace

apiVersion: v1
kind: Secret
metadata:
  annotations:
    serving.kserve.io/s3-region: [YOUR_REGION]
  name: agent-logger-secret
  namespace: default
type: Opaque
data:
  AWS_ACCESS_KEY_ID: [YOUR_ACCESS_KEY_ID]
  AWS_DEFAULT_REGION: [YOUR_REGION]
  AWS_SECRET_ACCESS_KEY: [YOUR_SECRET_ACCESS_KEY]

Create a service account for the secret:

apiVersion: v1
kind: ServiceAccount
metadata:
  name: logger-sa
  namespace: default
secrets:
- name: agent-logger-secret

To test the feature, deploy a model with inference logging:

apiVersion: serving.kserve.io/v1beta1
kind: InferenceService
metadata:
  name: sklearn-iris
spec:
  predictor:
    logger:
      mode: all
      url: s3://[YOUR_BUCKET]/
      storage:
        path: "/logger"
        parameters:
          type: s3
          format: json
        key: credentials
    model:
      modelFormat:
        name: sklearn
      storageUri: gs://kfserving-examples/models/sklearn/1.0/model

Send a prediction to the endpoint and the request and response are stored as json in the blob storage location [YOUR_BUCKET]/logger/

Documentation updated in PR 481

Release note:


Re-running failed tests

  • /rerun-all - rerun all failed workflows.
  • /rerun-workflow <workflow name> - rerun a specific failed workflow. Only one workflow name can be specified. Multiple /rerun-workflow commands are allowed per comment.

@cjohannsen-cloudera cjohannsen-cloudera force-pushed the cj/4380-inference-logging branch from bfc0b10 to 013211f Compare May 15, 2025 16:32
@cjohannsen-cloudera
Copy link
Author

/rerun-workflow test-llm
/rerun-workflow test-predictor
/rerun-workflow build

@cjohannsen-cloudera cjohannsen-cloudera force-pushed the cj/4380-inference-logging branch from bd59e67 to b15dca7 Compare May 16, 2025 17:07
@sivanantha321
Copy link
Member

@cjohannsen-cloudera
Copy link
Author

@cjohannsen-cloudera Can you help update the documentation as well ?https://github.com/kserve/website/blob/main/docs/modelserving/logger/logger.md

@sivanantha321 yes I can do that

@cjohannsen-cloudera
Copy link
Author

/rerun-workflow test

@cjohannsen-cloudera cjohannsen-cloudera force-pushed the cj/4380-inference-logging branch 3 times, most recently from e7a8f44 to e902eb4 Compare June 6, 2025 16:22
@cjohannsen-cloudera cjohannsen-cloudera force-pushed the cj/4380-inference-logging branch 2 times, most recently from 498eb54 to 4d2450b Compare June 11, 2025 17:37
cjohannsen-cloudera and others added 9 commits June 12, 2025 08:44
Signed-off-by: cory-johannsen <cjohannsen@cloudera.com>
Signed-off-by: cory-johannsen <cjohannsen@cloudera.com>
Signed-off-by: cory-johannsen <cjohannsen@cloudera.com>
Signed-off-by: cory-johannsen <cjohannsen@cloudera.com>
Signed-off-by: cory-johannsen <cjohannsen@cloudera.com>
Co-authored-by: Sivanantham <90966311+sivanantha321@users.noreply.github.com>
Signed-off-by: cjohannsen-cloudera <cjohannsen@cloudera.com>
Co-authored-by: Sivanantham <90966311+sivanantha321@users.noreply.github.com>
Signed-off-by: cjohannsen-cloudera <cjohannsen@cloudera.com>
Signed-off-by: cory-johannsen <cjohannsen@cloudera.com>
Signed-off-by: cory-johannsen <cjohannsen@cloudera.com>
@cjohannsen-cloudera cjohannsen-cloudera force-pushed the cj/4380-inference-logging branch from 4d2450b to 7082cbd Compare June 12, 2025 15:44
kfslogger.StartDispatcher(workers, logger)
var store kfslogger.Store
if kfslogger.GetStorageStrategy(*logUrl) != kfslogger.HttpStorage {
if logStoreFormat != nil && *logStoreFormat != "" && logStorePath != nil && *logStorePath != "" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can have a default for logFromat ?

storageSecretName = secretName

// if the secret name is provided use it
if secretName != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have a test case for this ?

8000
@@ -46,6 +48,7 @@ const (
LoggerArgumentTlsSkipVerify = "--logger-tls-skip-verify"
LoggerArgumentMetadataHeaders = "--metadata-headers"
LoggerArgumentMetadataAnnotations = "--metadata-annotations"
LoggerDefaultServiceAccountName = "logger-sa"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this default name configurable ?

@@ -56,16 +59,22 @@ type AgentConfig struct {
MemoryLimit string `json:"memoryLimit"`
}

type LoggerStorageSpec struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type is already defined in the pkg/apis/serving/v1beta1/inference_service.go. We can reuse that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for writing model request/response logs to object stores
2 participants
0