// Module included in the following assemblies:
//
// * support/remote_health_monitoring/remote-health-reporting-from-restricted-network.adoc

:_mod-docs-content-type: PROCEDURE
[id="insights-operator-one-time-gather_{context}"]
= Running an {insights-operator} gather operation

[role="_abstract"]
You must run a gather operation to create an {insights-operator} archive.

.Prerequisites

* You are logged in to {product-title} as `cluster-admin`.

.Procedure

. Create a file named `gather-job.yaml` using this template:
+
[source,yaml]
----
include::https://raw.githubusercontent.com/openshift/insights-operator/release-4.22/docs/gather-job.yaml[]
----

. Copy your `insights-operator` image version:
+
[source,terminal]
----
$ oc get -n openshift-insights deployment insights-operator -o yaml
----
+
.Example output
[source,yaml]
----
apiVersion: apps/v1
kind: Deployment
metadata:
  name: insights-operator
  namespace: openshift-insights
# ...
spec:
  template:
# ...
    spec:
      containers:
      - args:
# ...
        image: registry.ci.openshift.org/ocp/4.15-2023-10-12-212500@sha256:a0aa581400805ad0...
# ...
----
+
The `spec.template.spec.containers.image` field specifies your `insights-operator` image version.

. Paste your image version in `gather-job.yaml`:
+
[source,yaml,subs="+quotes"]
----
apiVersion: batch/v1
kind: Job
metadata:
  name: insights-operator-job
# ...
spec:
# ...
  template:
    spec:
    initContainers:
    - name: insights-operator
      image: image: registry.ci.openshift.org/ocp/4.15-2023-10-12-212500@sha256:a0aa581400805ad0...
      terminationMessagePolicy: FallbackToLogsOnError
      volumeMounts:
----
+
Replace the value of `spec.template.initContainers.image` with your `insights-operator` image version.

. Create the gather job:
+
[source,terminal]
----
$ oc apply -n openshift-insights -f gather-job.yaml
----

. Find the name of the job pod:
+
[source,terminal]
----
$ oc describe -n openshift-insights job/insights-operator-job
----
+
.Example output
[source,terminal,subs="+quotes"]
----
Name:             insights-operator-job
Namespace:        openshift-insights
# ...
Events:
  Type    Reason            Age    From            Message
  ----    ------            ----   ----            -------
  Normal  SuccessfulCreate  7m18s  job-controller  Created pod: insights-operator-job-<your_job>
----
+
Replace `insights-operator-job-<your_job>` with the name of the pod.

. Verify that the operation has finished:
+
[source,terminal,subs="+quotes"]
----
$ oc logs -n openshift-insights insights-operator-job-<your_job> insights-operator
----
+
.Example output
[source,terminal]
----
I0407 11:55:38.192084       1 diskrecorder.go:34] Wrote 108 records to disk in 33ms
----

. Save the created archive:
+
[source,terminal,subs="+quotes"]
----
$ oc cp openshift-insights/insights-operator-job-_<your_job>_:/var/lib/insights-operator ./insights-data
----

. Clean up the job:
+
[source,terminal]
----
$ oc delete -n openshift-insights job insights-operator-job
----
