Collector for Kubernetesコマンドリファレンス

Splunk Distribution of OpenTelemetry Collector で最もよく使用されるコマンドです。

次の表は、Splunk Distribution of OpenTelemetry Collector for Kubernetes のコンテキストにおける、すべてのコマンドとその使用法の一覧です。コマンドを選択すると、より詳細な説明と構文の例が表示されます。

コマンド

使用状況

helm delete

OpenTelemetry Collector Helm チャートリポジトリの Splunk ディストリビューションを削除する

helm install

OpenTelemetry Collector Helm チャートリポジトリの Splunk ディストリビューションをデプロイする

helm repo add

Splunk Distribution of OpenTelemetry Collector Helm チャートリポジトリを追加する

helm repo update

OpenTelemetry Collector Helm チャートリポジトリの Splunk ディストリビューションを更新する

journalctl

ホストのコレクタログをチェックする

kubectl config

Kubernetesの設定を変更する

kubectl create

Kubernetesリソースを作成する

kubectl delete

Kubernetesリソースを削除する

kubectl describe

Kubernetesのシステム構成を確認する

kubectl edit

Kubernetes リソースを編集します。このコマンドは、初期設定、効果的な設定、および Collector のステータスの確認に使用します。

kubectl exec

Kubernetesコンテナでコマンドを実行する

kubectl get

Kubernetes上で稼働している1つまたは複数のリソースを表示する

kubectl logs

Kubernetesコンテナのログをチェックする

restart

ホスト上でコレクタを再起動します。

start

ホスト上でコレクタを起動します。

status

ホストのコレクタステータスをチェックする(Linux のみ)

stop

ホスト上のコレクタを停止します。

helm delete

説明

Splunk Distribution of OpenTelemetry Collector Helm チャートリポジトリを削除します。

構文

helm delete splunk-otel-collector

helm install

説明

Splunk Distribution of OpenTelemetry Collector Helm チャートリポジトリをデプロイします。

構文

helm install splunk-otel-collector \
--set="splunkRealm=$REALM" \
--set="splunkAccessToken=$ACCESS_TOKEN" \
--set="clusterName=<MY-CLUSTER>" \
--set="logsEnabled=false" \
--set="environment=$<MY-ENV>" \
splunk-otel-collector-chart/splunk-otel-collector \
-f ~/workshop/k3s/otel-collector.yaml

YAML ファイルを使用して、引数として Helm 値を設定することもできます。たとえば、my_values.yaml という名前の YAML ファイルを作成した後で、次のコマンドを実行して Helm チャートをデプロイします。

helm install my-splunk-otel-collector --values my_values.yaml splunk-otel-collector-chart/splunk-otel-collector

helm repo add

説明

Splunk Distribution of OpenTelemetry Collector Helm チャートリポジトリを追加します。

構文

helm repo add splunk-otel-collector-chart https://signalfx.github.io/splunk-otel-collector-chart

# Use these two commands together to add and update the repository at the same time
helm repo add splunk-otel-collector-chart https://signalfx.github.io/splunk-otel-collector-chart && helm repo update

helm repo update

説明

Splunk Distribution of OpenTelemetry Collector Helm チャートリポジトリを更新します。

構文

helm repo update https://signalfx.github.io/splunk-otel-collector-chart

journalctl

説明

ホストのコレクタログをチェックします。

構文

journalctl -u splunk-otel-collector -f
tail -100 /var/log/messages

オプションの引数

引数

説明

-f

新しいログエントリーが追加されるときに表示する

tail -100

ログファイルから過去100行のログを取得する

-u

指定された systemd ユニット UNIT (サービスユニットなど)、または PATTERN でマッチしたユニットのメッセージを表示します。

/var/log/messages

ログメッセージの表示元のファイル

kubectl config

説明

サブコマンドを使用して、Kubernetes の設定を変更します。サブコマンドやオプション引数の一覧全文については、Kubectl Reference Documentation を参照してください。

構文

kubectl config [subcommand]

# Examples

# Show kubeconfig settings
kubectl config view

# Save namespace for all subsequent kubectl commands in context
kubectl config set-context --current --namespace=ggckad-s2

# Get the password for the e2e user
kubectl config view -o jsonpath='{.users[?(@.name == "e2e")].user.password}'

# Display the first user
kubectl config view -o jsonpath='{.users[].name}'

# Get a list of users
kubectl config view -o jsonpath='{.users[*].name}'

# Display list of contexts
kubectl config get-contexts

# Display the current-context
kubectl config current-context

# Set the default context to my-cluster-name
kubectl config use-context my-cluster-name

# Add a new user to your kubeconfig that supports basic authorization
kubectl config set-credentials kubeuser/foo.kubernetes.com --username=kubeuser --password=kubepassword

# Set a context utilizing a specific username and namespace
kubectl config set-context gce --user=cluster-admin --namespace=foo \ && kubectl config use-context gce

kubectl create

説明

ファイルから Kubernetes リソースを作成します。対応ファイル形式は JSON と YAML です。サブコマンドやオプション引数の一覧全文については、Kubectl Reference Documentation を参照してください。

構文

sudo kubectl create -f <file-name>

# Examples

# Use the subcommand configmap to create a ConfigMap from a source file
sudo kubectl create configmap <map-name> --from-file=<file path>

オプションの引数

引数

説明

-f

リソースを作成するソースファイル

--from-file

ConfigMapを作成するソースファイルへのパス。

<map-name>

ConfigMapの名前

kubectl delete

説明

ソースファイルから Kubernetes リソースを削除します。サブコマンドやオプション引数の一覧全文については、Kubectl Reference Documentation を参照してください。

構文

sudo kubectl delete -f <file-name>

オプションの引数

引数

説明

-f

リソースを削除するソースファイル

kubectl describe

説明

Kubernetesのシステム構成を確認します。

構文

kubectl describe -n <namepsace> pod <pod-name>

オプションの引数

引数

説明

-n

コンフィギュレーションをチェックする名前空間

pod

設定をチェックするポッド

kubectl edit

説明

Kubernetesコンテナ上で動作するリソースを編集します。

構文

kubectl edit cm <name>
kubectl edit ds <name>

オプションの引数

引数

説明

cm

変更したい項目がConfigMapであることを指定する

ds

変更する項目がDaemonSetであることを指定する

<name>

変更したいリソースの名前

kubectl exec

説明

Kubernetesコンテナでコマンドを実行します。

構文

kubectl exec -it <container/pod> -- curl <commands>

# Examples

# Initial configuration
kubectl exec -it my-splunk-otel-collector-agent-hg4gk -- curl http://localhost:55554/debug/configz/initial

# Effective configuration
kubectl exec -it my-splunk-otel-collector-agent-hg4gk -- curl http://localhost:55554/debug/effective

# Check status of the collector
kubectl exec -it <your-agent-pod> -- curl localhost:55679/debug/tracez | lynx -stdin
kubectl exec -it splunk-otel-collector-agent-f4gwg -- curl localhost:55679/debug/tracez | lynx -stdin

オプションの引数

引数

説明

-it

エージェントポッド

-- curl

その他の curl コマンド

kubectl get

説明

Kubernetes上で稼働している1つまたは複数のリソースを表示します。

構文

kubectl get pods -n <namespace>
kubectl get configmap
kubectl get ds

オプションの引数

引数

説明

configmap

ConfigMapを表示する

ds

デーモンセットを表示する

-n

名前空間

pods

プロセス・ステータス出力形式ですべてのポッドをリストする

kubectl logs

説明

Kubernetesコンテナのログをチェックします。

構文

sudo kubectl logs <pod-name | type/name> -l <label> -f -c <container-name>

# Examples

# Return snapshot logs from pod nginx with only one container
kubectl logs nginx

# Return snapshot logs from pod nginx with multiple containers
kubectl logs nginx --all-containers=true

# Return snapshot logs from all containers in pods defined by label app=nginx
kubectl logs -l app=nginx --all-containers=true

# Return snapshot of previous terminated ruby container logs from pod web-1
kubectl logs web-1 -p -c ruby

# Begin streaming the logs of the ruby container in pod web-1
kubectl logs web-1 -f -c ruby

# Begin streaming the logs from all containers in pods defined by label app=nginx
kubectl logs -f -l app=nginx --all-containers=true

# Display only the most recent 20 lines of output in pod nginx
kubectl logs nginx --tail=20

# Show all logs from pod nginx written in the last hour
kubectl logs nginx --since=1h

# Show logs from a kubelet with an expired serving certificate
kubectl logs nginx --insecure-skip-tls-verify-backend

# Return snapshot logs from first container of a job named hello
kubectl logs job/hello

# Return snapshot logs from container nginx-1 of a deployment named nginx
kubectl logs deployment/nginx -c nginx-1

オプションの引数

引数

説明

--all-containers

true の場合、ポッド内のすべてのコンテナのログを取得します。デフォルト値 false

-c

ログの表示元のコンテナ

-f

新しいログエントリーが追加されるときに表示する

--insecure-skip-tls-verify-backend

ログを取得する kubelet の識別情報の検証をスキップします。有効期限切れのサービス提供証明書を持つ kubelet からログを取得したい場合に使用します。

-l

フィルターリングするラベル

-p

true の場合、ポッド内にコンテナの前のインスタンスが存在する場合に、そのインスタンスのログを表示します。デフォルト値 false

--since

指定した期間内の最新のログのみを取得します

--tail

表示する直近のログの行数

再起動

説明

ホスト上で Collector を再起動します。Fluentd サービスがインストールされている場合は、sudo systemctl restart td-agent を使って再起動することもできます。

構文

sudo systemctl restart splunk-otel-collector

起動

説明

ホスト上で Collector を起動します。Fluentd サービスがインストールされている場合は、sudo systemctl start td-agent を使って起動することもできます。

構文

sudo systemctl start splunk-otel-collector

status

説明

ホスト上の Collector のステータスをチェックします。Linux でのみ使用できます。

Health Check 拡張機能を使用することで、HTTP URL をプローブして OpenTelemetry Collector の状態を確認することも可能です。

構文

sudo systemctl status splunk-otel-collector

停止

説明

ホスト上の Collector を停止します。Fluentd サービスがインストールされている場合は、sudo systemctl stop td-agent を使って停止することもできます。

構文

sudo systemctl stop splunk-otel-collector