diff --git a/ee/tables/osquery_instance_history/osquery_instance_history.go b/ee/tables/osquery_instance_history/osquery_instance_history.go index 0bdf79788..5cce87e2f 100644 --- a/ee/tables/osquery_instance_history/osquery_instance_history.go +++ b/ee/tables/osquery_instance_history/osquery_instance_history.go @@ -9,7 +9,7 @@ import ( func TablePlugin() *table.Plugin { columns := []table.ColumnDefinition{ - table.TextColumn("internal_id"), + table.TextColumn("instance_run_id"), table.TextColumn("start_time"), table.TextColumn("connect_time"), table.TextColumn("exit_time"), @@ -33,14 +33,14 @@ func generate() table.GenerateFunc { for _, instance := range history { results = append(results, map[string]string{ - "internal_id": instance.InternalId, - "start_time": instance.StartTime, - "connect_time": instance.ConnectTime, - "exit_time": instance.ExitTime, - "instance_id": instance.InstanceId, - "version": instance.Version, - "hostname": instance.Hostname, - "errors": instance.Error, + "instance_run_id": instance.RunId, + "start_time": instance.StartTime, + "connect_time": instance.ConnectTime, + "exit_time": instance.ExitTime, + "instance_id": instance.InstanceId, + "version": instance.Version, + "hostname": instance.Hostname, + "errors": instance.Error, }) } diff --git a/pkg/osquery/runtime/history/history.go b/pkg/osquery/runtime/history/history.go index 84a894b5f..57ae0a6c0 100644 --- a/pkg/osquery/runtime/history/history.go +++ b/pkg/osquery/runtime/history/history.go @@ -88,7 +88,7 @@ func LatestInstanceUptimeMinutes() (int64, error) { } // NewInstance adds a new instance to the osquery instance history and returns it -func NewInstance(internalId string) (*Instance, error) { +func NewInstance(runId string) (*Instance, error) { currentHistory.Lock() defer currentHistory.Unlock() @@ -98,9 +98,9 @@ func NewInstance(internalId string) (*Instance, error) { } newInstance := &Instance{ - InternalId: internalId, - StartTime: timeNow(), - Hostname: hostname, + RunId: runId, + StartTime: timeNow(), + Hostname: hostname, } currentHistory.addInstanceToHistory(newInstance) diff --git a/pkg/osquery/runtime/history/instance.go b/pkg/osquery/runtime/history/instance.go index a9c187803..aaf65f22a 100644 --- a/pkg/osquery/runtime/history/instance.go +++ b/pkg/osquery/runtime/history/instance.go @@ -6,7 +6,7 @@ import ( ) type Instance struct { - InternalId string // ID assigned by launcher + RunId string // ID for instance, assigned by launcher StartTime string ConnectTime string ExitTime string diff --git a/pkg/osquery/runtime/osqueryinstance.go b/pkg/osquery/runtime/osqueryinstance.go index 11aa8e001..6e9173dd6 100644 --- a/pkg/osquery/runtime/osqueryinstance.go +++ b/pkg/osquery/runtime/osqueryinstance.go @@ -106,7 +106,7 @@ type OsqueryInstance struct { serviceClient service.KolideService // the following are instance artifacts that are created and held as a result // of launching an osqueryd process - id string // string identifier for this instance + runId string // string identifier for this instance errgroup *errgroup.Group saasExtension *launcherosq.Extension doneCtx context.Context // nolint:containedctx @@ -189,12 +189,12 @@ type osqueryOptions struct { } func newInstance(knapsack types.Knapsack, serviceClient service.KolideService, opts ...OsqueryInstanceOption) *OsqueryInstance { - id := ulid.New() + runId := ulid.New() i := &OsqueryInstance{ knapsack: knapsack, - slogger: knapsack.Slogger().With("component", "osquery_instance", "internal_id", id), + slogger: knapsack.Slogger().With("component", "osquery_instance", "instance_run_id", runId), serviceClient: serviceClient, - id: id, + runId: runId, } for _, opt := range opts { @@ -260,7 +260,7 @@ func (i *OsqueryInstance) Launch() error { // Based on the root directory, calculate the file names of all of the // required osquery artifact files. - paths, err := calculateOsqueryPaths(i.knapsack.RootDirectory(), i.id, i.opts) + paths, err := calculateOsqueryPaths(i.knapsack.RootDirectory(), i.runId, i.opts) if err != nil { traces.SetError(span, fmt.Errorf("could not calculate osquery file paths: %w", err)) return fmt.Errorf("could not calculate osquery file paths: %w", err) @@ -360,7 +360,7 @@ func (i *OsqueryInstance) Launch() error { "osquery socket created", ) - stats, err := history.NewInstance(i.id) + stats, err := history.NewInstance(i.runId) if err != nil { i.slogger.Log(ctx, slog.LevelWarn, "could not create new osquery instance history", @@ -665,12 +665,12 @@ type osqueryFilePaths struct { // In return, a structure of paths is returned that can be used to launch an // osqueryd instance. An error may be returned if the supplied parameters are // unacceptable. -func calculateOsqueryPaths(rootDirectory string, id string, opts osqueryOptions) (*osqueryFilePaths, error) { +func calculateOsqueryPaths(rootDirectory string, runId string, opts osqueryOptions) (*osqueryFilePaths, error) { // Determine the path to the extension socket extensionSocketPath := opts.extensionSocketPath if extensionSocketPath == "" { - extensionSocketPath = SocketPath(rootDirectory, id) + extensionSocketPath = SocketPath(rootDirectory, runId) } extensionAutoloadPath := filepath.Join(rootDirectory, "osquery.autoload") @@ -678,7 +678,7 @@ func calculateOsqueryPaths(rootDirectory string, id string, opts osqueryOptions) // We want to use a unique pidfile per launcher run to avoid file locking issues. // See: https://github.com/kolide/launcher/issues/1599 osqueryFilePaths := &osqueryFilePaths{ - pidfilePath: filepath.Join(rootDirectory, fmt.Sprintf("osquery-%s.pid", id)), + pidfilePath: filepath.Join(rootDirectory, fmt.Sprintf("osquery-%s.pid", runId)), databasePath: filepath.Join(rootDirectory, "osquery.db"), augeasPath: filepath.Join(rootDirectory, "augeas-lenses"), extensionSocketPath: extensionSocketPath,