diff --git a/assets/src/generated/graphql-plural.ts b/assets/src/generated/graphql-plural.ts index d90438890..4c84c9e83 100644 --- a/assets/src/generated/graphql-plural.ts +++ b/assets/src/generated/graphql-plural.ts @@ -385,6 +385,11 @@ export enum CloudProvider { Aws = 'AWS' } +export type CloudRegions = { + __typename?: 'CloudRegions'; + aws?: Maybe>>; +}; + export type CloudShell = { __typename?: 'CloudShell'; aesKey: Scalars['String']['output']; @@ -2208,6 +2213,17 @@ export type PlatformSubscriptionLineItems = { quantity: Scalars['Int']['output']; }; +export type PluralCloudRegions = { + __typename?: 'PluralCloudRegions'; + dedicated: CloudRegions; + shared: CloudRegions; +}; + +export type PluralCloudSettings = { + __typename?: 'PluralCloudSettings'; + regions?: Maybe; +}; + export type PluralConfiguration = { __typename?: 'PluralConfiguration'; gitCommit?: Maybe; @@ -3408,7 +3424,7 @@ export type RootMutationTypeLinkPublisherArgs = { export type RootMutationTypeLoginArgs = { - captcha?: InputMaybe; + captcha: Scalars['String']['input']; deviceToken?: InputMaybe; email: Scalars['String']['input']; password: Scalars['String']['input']; @@ -3733,6 +3749,7 @@ export type RootQueryType = { charts?: Maybe; chat?: Maybe; closure?: Maybe>>; + cloudSettings?: Maybe; /** Get a cluster by its ID. */ cluster?: Maybe; /** Get a list of clusters owned by the current account. */ diff --git a/assets/src/generated/graphql.ts b/assets/src/generated/graphql.ts index 2e73d11cd..6fde4d1c2 100644 --- a/assets/src/generated/graphql.ts +++ b/assets/src/generated/graphql.ts @@ -2444,6 +2444,19 @@ export type IngressTls = { hosts?: Maybe>>; }; +export type InsightClientInfo = { + __typename?: 'InsightClientInfo'; + count?: Maybe; + lastRequestAt?: Maybe; + userAgent?: Maybe; +}; + +export type InsightClientInfoAttributes = { + count?: InputMaybe; + lastRequestAt?: InputMaybe; + userAgent?: InputMaybe; +}; + export type Installation = { __typename?: 'Installation'; id: Scalars['ID']['output']; @@ -7040,6 +7053,8 @@ export type RuntimeService = { addonVersion?: Maybe; id: Scalars['ID']['output']; insertedAt?: Maybe; + /** the number of instances of this service we've detected */ + instanceCount?: Maybe; /** add-on name */ name: Scalars['String']['output']; /** the plural service it came from */ @@ -7050,6 +7065,8 @@ export type RuntimeService = { }; export type RuntimeServiceAttributes = { + /** the number of instances of this service we've found */ + instanceCount?: InputMaybe; name: Scalars['String']['input']; version: Scalars['String']['input']; }; @@ -8204,6 +8221,8 @@ export type UpgradeInsightAttributes = { export type UpgradeInsightDetail = { __typename?: 'UpgradeInsightDetail'; + /** information about the HTTP clients triggering this insight */ + clientInfo?: Maybe>>; id: Scalars['ID']['output']; insertedAt?: Maybe; lastUsedAt?: Maybe; @@ -8218,6 +8237,8 @@ export type UpgradeInsightDetail = { }; export type UpgradeInsightDetailAttributes = { + /** descriptions of the HTTP clients triggering this insight */ + clientInfo?: InputMaybe>>; /** the latest timestamp this insight has been observed */ lastUsedAt?: InputMaybe; removedIn?: InputMaybe; diff --git a/go/client/models_gen.go b/go/client/models_gen.go index 920eca3c3..7f42d551d 100644 --- a/go/client/models_gen.go +++ b/go/client/models_gen.go @@ -2004,6 +2004,18 @@ type IngressTLS struct { Hosts []*string `json:"hosts,omitempty"` } +type InsightClientInfo struct { + UserAgent *string `json:"userAgent,omitempty"` + Count *string `json:"count,omitempty"` + LastRequestAt *string `json:"lastRequestAt,omitempty"` +} + +type InsightClientInfoAttributes struct { + UserAgent *string `json:"userAgent,omitempty"` + Count *string `json:"count,omitempty"` + LastRequestAt *string `json:"lastRequestAt,omitempty"` +} + type Installation struct { ID string `json:"id"` Repository *Repository `json:"repository,omitempty"` @@ -4036,6 +4048,8 @@ type RuntimeService struct { Name string `json:"name"` // add-on version, should be semver formatted Version string `json:"version"` + // the number of instances of this service we've detected + InstanceCount *int64 `json:"instanceCount,omitempty"` // the full specification of this kubernetes add-on Addon *RuntimeAddon `json:"addon,omitempty"` // the version of the add-on you've currently deployed @@ -4049,6 +4063,8 @@ type RuntimeService struct { type RuntimeServiceAttributes struct { Name string `json:"name"` Version string `json:"version"` + // the number of instances of this service we've found + InstanceCount *int64 `json:"instanceCount,omitempty"` } type S3Store struct { @@ -5035,11 +5051,13 @@ type UpgradeInsightDetail struct { Used *string `json:"used,omitempty"` // the replacement for this API Replacement *string `json:"replacement,omitempty"` - ReplacedIn *string `json:"replacedIn,omitempty"` - RemovedIn *string `json:"removedIn,omitempty"` - LastUsedAt *string `json:"lastUsedAt,omitempty"` - InsertedAt *string `json:"insertedAt,omitempty"` - UpdatedAt *string `json:"updatedAt,omitempty"` + // information about the HTTP clients triggering this insight + ClientInfo []*InsightClientInfo `json:"clientInfo,omitempty"` + ReplacedIn *string `json:"replacedIn,omitempty"` + RemovedIn *string `json:"removedIn,omitempty"` + LastUsedAt *string `json:"lastUsedAt,omitempty"` + InsertedAt *string `json:"insertedAt,omitempty"` + UpdatedAt *string `json:"updatedAt,omitempty"` } type UpgradeInsightDetailAttributes struct { @@ -5048,8 +5066,10 @@ type UpgradeInsightDetailAttributes struct { Used *string `json:"used,omitempty"` // the replacement for this API Replacement *string `json:"replacement,omitempty"` - ReplacedIn *string `json:"replacedIn,omitempty"` - RemovedIn *string `json:"removedIn,omitempty"` + // descriptions of the HTTP clients triggering this insight + ClientInfo []*InsightClientInfoAttributes `json:"clientInfo,omitempty"` + ReplacedIn *string `json:"replacedIn,omitempty"` + RemovedIn *string `json:"removedIn,omitempty"` // the latest timestamp this insight has been observed LastUsedAt *string `json:"lastUsedAt,omitempty"` } diff --git a/lib/console/graphql/deployments/cluster.ex b/lib/console/graphql/deployments/cluster.ex index f52f2d426..da4db921d 100644 --- a/lib/console/graphql/deployments/cluster.ex +++ b/lib/console/graphql/deployments/cluster.ex @@ -167,8 +167,9 @@ defmodule Console.GraphQl.Deployments.Cluster do end input_object :runtime_service_attributes do - field :name, non_null(:string) - field :version, non_null(:string) + field :name, non_null(:string) + field :version, non_null(:string) + field :instance_count, :integer, description: "the number of instances of this service we've found" end input_object :agent_migration_attributes do @@ -212,6 +213,7 @@ defmodule Console.GraphQl.Deployments.Cluster do field :status, :upgrade_insight_status field :used, :string, description: "a possibly deprecated API" field :replacement, :string, description: "the replacement for this API" + field :client_info, list_of(:insight_client_info_attributes), description: "descriptions of the HTTP clients triggering this insight" field :replaced_in, :string field :removed_in, :string @@ -219,6 +221,12 @@ defmodule Console.GraphQl.Deployments.Cluster do field :last_used_at, :datetime, description: "the latest timestamp this insight has been observed" end + input_object :insight_client_info_attributes do + field :user_agent, :string + field :count, :string + field :last_request_at, :datetime + end + @desc "a CAPI provider for a cluster, cloud is inferred from name if not provided manually" object :cluster_provider do field :id, non_null(:id), description: "the id of this provider" @@ -527,12 +535,13 @@ defmodule Console.GraphQl.Deployments.Cluster do @desc "a service encapsulating a controller like istio/ingress-nginx/etc that is meant to extend the kubernetes api" object :runtime_service do - field :id, non_null(:id) - field :name, non_null(:string), description: "add-on name" - field :version, non_null(:string), description: "add-on version, should be semver formatted" - field :addon, :runtime_addon, description: "the full specification of this kubernetes add-on" - field :addon_version, :addon_version, description: "the version of the add-on you've currently deployed" - field :service, :service_deployment, + field :id, non_null(:id) + field :name, non_null(:string), description: "add-on name" + field :version, non_null(:string), description: "add-on version, should be semver formatted" + field :instance_count, :integer, description: "the number of instances of this service we've detected" + field :addon, :runtime_addon, description: "the full specification of this kubernetes add-on" + field :addon_version, :addon_version, description: "the version of the add-on you've currently deployed" + field :service, :service_deployment, resolve: dataloader(Deployments), description: "the plural service it came from" @@ -640,6 +649,7 @@ defmodule Console.GraphQl.Deployments.Cluster do field :status, :upgrade_insight_status field :used, :string, description: "a possibly deprecated API" field :replacement, :string, description: "the replacement for this API" + field :client_info, list_of(:insight_client_info), description: "information about the HTTP clients triggering this insight" field :replaced_in, :string field :removed_in, :string @@ -648,6 +658,12 @@ defmodule Console.GraphQl.Deployments.Cluster do timestamps() end + object :insight_client_info do + field :user_agent, :string + field :count, :string + field :last_request_at, :datetime + end + connection node_type: :cluster connection node_type: :cluster_provider connection node_type: :cluster_revision diff --git a/lib/console/schema/runtime_service.ex b/lib/console/schema/runtime_service.ex index f6d83bfbd..a116e3d7d 100644 --- a/lib/console/schema/runtime_service.ex +++ b/lib/console/schema/runtime_service.ex @@ -3,8 +3,9 @@ defmodule Console.Schema.RuntimeService do alias Console.Schema.{Service, Cluster} schema "runtime_services" do - field :name, :string - field :version, :string + field :name, :string + field :version, :string + field :instance_count, :integer, default: 1 field :addon, :map, virtual: true field :addon_version, :map, virtual: true @@ -27,7 +28,7 @@ defmodule Console.Schema.RuntimeService do from(rs in query, order_by: ^order) end - @valid ~w(name version service_id cluster_id)a + @valid ~w(name version instance_count service_id cluster_id)a def changeset(model, attrs \\ %{}) do model diff --git a/lib/console/schema/upgrade_insight_detail.ex b/lib/console/schema/upgrade_insight_detail.ex index 39d8087d9..d87ba6f19 100644 --- a/lib/console/schema/upgrade_insight_detail.ex +++ b/lib/console/schema/upgrade_insight_detail.ex @@ -7,6 +7,12 @@ defmodule Console.Schema.UpgradeInsightDetail do field :used, :string field :replacement, :string + embeds_many :client_info, ClientInfo, on_replace: :delete do + field :user_agent, :string + field :count, :string + field :last_request_at, :utc_datetime_usec + end + field :replaced_in, :string field :removed_in, :string @@ -20,7 +26,14 @@ defmodule Console.Schema.UpgradeInsightDetail do def changeset(model, attrs \\ %{}) do model |> cast(attrs, ~w(status used replacement replaced_in removed_in insight_id last_used_at)a) + |> cast_embed(:client_info, with: &client_info_changeset/2) |> foreign_key_constraint(:insight_id) |> validate_required(~w(status used replacement)a) end + + defp client_info_changeset(model, attrs) do + model + |> cast(attrs, ~w(user_agent count last_request_at)a) + |> validate_required(~w(user_agent last_request_at)a) + end end diff --git a/priv/repo/migrations/20241003160915_insight_detail.exs b/priv/repo/migrations/20241003160915_insight_detail.exs new file mode 100644 index 000000000..9f1d843f2 --- /dev/null +++ b/priv/repo/migrations/20241003160915_insight_detail.exs @@ -0,0 +1,13 @@ +defmodule Console.Repo.Migrations.InsightDetail do + use Ecto.Migration + + def change do + alter table(:upgrade_insight_details) do + add :client_info, :map + end + + alter table(:runtime_services) do + add :instance_count, :integer, default: 1 + end + end +end diff --git a/schema/schema.graphql b/schema/schema.graphql index da6288c14..6ac859343 100644 --- a/schema/schema.graphql +++ b/schema/schema.graphql @@ -3725,7 +3725,11 @@ input AzureSettingsAttributes { input RuntimeServiceAttributes { name: String! + version: String! + + "the number of instances of this service we've found" + instanceCount: Int } input AgentMigrationAttributes { @@ -3781,6 +3785,9 @@ input UpgradeInsightDetailAttributes { "the replacement for this API" replacement: String + "descriptions of the HTTP clients triggering this insight" + clientInfo: [InsightClientInfoAttributes] + replacedIn: String removedIn: String @@ -3789,6 +3796,12 @@ input UpgradeInsightDetailAttributes { lastUsedAt: DateTime } +input InsightClientInfoAttributes { + userAgent: String + count: String + lastRequestAt: DateTime +} + "a CAPI provider for a cluster, cloud is inferred from name if not provided manually" type ClusterProvider { "the id of this provider" @@ -4217,6 +4230,9 @@ type RuntimeService { "add-on version, should be semver formatted" version: String! + "the number of instances of this service we've detected" + instanceCount: Int + "the full specification of this kubernetes add-on" addon: RuntimeAddon @@ -4348,6 +4364,9 @@ type UpgradeInsightDetail { "the replacement for this API" replacement: String + "information about the HTTP clients triggering this insight" + clientInfo: [InsightClientInfo] + replacedIn: String removedIn: String @@ -4359,6 +4378,12 @@ type UpgradeInsightDetail { updatedAt: DateTime } +type InsightClientInfo { + userAgent: String + count: String + lastRequestAt: DateTime +} + type ClusterConnection { pageInfo: PageInfo! edges: [ClusterEdge]