Skip to main content

Setup Scraping for sending to Polar Signals Cloud

While the primary way to write data to Polar Signals Cloud is to use the agent, there may be reasons to want to write additional data that cannot be obtained via the agent.

Languages

Here is a table of Languages/runtimes and libraries that can be used to gather additional types of profiling data.

Language/runtimeHeapAllocationsBlockingMutex ContentionExtra
GoYesYesYesYesGoroutine, fgprof
PythonYesNoNoNo
NodeJSYesNoNoNo

Setup

The below manifests deploy the Polar Signals scraper, which discovers containers in a Kubernetes cluster and starts scraping them.

info

The configuration is identical to the Prometheus scrape config, Kubernetes is just used as an example here.

kubectl apply -f polarsignals-scraper.yaml
---
apiVersion: v1
kind: Namespace
metadata:
name: polarsignals
labels:
pod-security.kubernetes.io/audit: privileged
pod-security.kubernetes.io/enforce: privileged
pod-security.kubernetes.io/warn: privileged
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
app.kubernetes.io/component: profile-scraper
app.kubernetes.io/instance: polarsignals-scraper
app.kubernetes.io/name: polarsignals-scraper
name: polarsignals-scraper
namespace: polarsignals
rules:
- apiGroups:
- ""
resources:
- pods
verbs:
- list
- watch
- apiGroups:
- ""
resources:
- nodes
verbs:
- get
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
labels:
app.kubernetes.io/component: profile-scraper
app.kubernetes.io/instance: polarsignals-scraper
app.kubernetes.io/name: polarsignals-scraper
name: polarsignals-scraper
namespace: polarsignals
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: polarsignals-scraper
subjects:
- kind: ServiceAccount
name: polarsignals-scraper
namespace: polarsignals
---
kind: ConfigMap
metadata:
name: polarsignals-scraper-config
namespace: polarsignals
apiVersion: v1
data:
polarsignals-scraper.yaml: |-
object_storage:
bucket:
type: "FILESYSTEM"
config:
directory: "./data"
# MODIFY THIS TO YOUR NEEDS
scrape_configs:
- job_name: 'kubernetes-pods'
kubernetes_sd_configs:
- role: pod
relabel_configs:
- action: labelmap
regex: __meta_kubernetes_pod_label_app_kubernetes_io_(.+)
replacement: "app_kubernetes_io_$1"
- source_labels: [__meta_kubernetes_namespace]
action: replace
target_label: namespace
- source_labels: [__meta_kubernetes_pod_name]
action: replace
target_label: pod
- source_labels: [__meta_kubernetes_pod_container_name]
action: replace
target_label: container
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/component: profile-scraper
app.kubernetes.io/instance: polarsignals-scraper
app.kubernetes.io/name: polarsignals-scraper
name: polarsignals-scraper
namespace: polarsignals
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/component: profile-scraper
app.kubernetes.io/instance: polarsignals-scraper
app.kubernetes.io/name: polarsignals-scraper
template:
metadata:
labels:
app.kubernetes.io/component: profile-scraper
app.kubernetes.io/instance: polarsignals-scraper
app.kubernetes.io/name: polarsignals-scraper
app.kubernetes.io/version: v0.20.0
spec:
securityContext:
fsGroup: 65534
runAsUser: 65534
containers:
- args:
- /parca
- --config-path=/var/polarsignals-scraper/polarsignals-scraper.yaml
- --store-address=grpc.polarsignals.com:443
- --bearer-token-file=/var/polarsignals-secret/token
- --mode=scraper-only
image: ghcr.io/parca-dev/parca:v0.20.0
livenessProbe:
exec:
command:
- /grpc_health_probe
- -v
- -addr=:7070
initialDelaySeconds: 5
name: polarsignals-scraper
ports:
- containerPort: 7070
name: http
readinessProbe:
exec:
command:
- /grpc_health_probe
- -v
- -addr=:7070
initialDelaySeconds: 10
terminationMessagePolicy: FallbackToLogsOnError
resources: {}
volumeMounts:
- mountPath: /tmp
name: tmp
- mountPath: /var/polarsignals-scraper
name: polarsignals-scraper-config
- mountPath: /var/polarsignals-secret
name: token
nodeSelector:
kubernetes.io/os: linux
serviceAccountName: polarsignals-scraper
tolerations:
- effect: NoSchedule
operator: Exists
- effect: NoExecute
operator: Exists
volumes:
- emptyDir: {}
name: tmp
- configMap:
name: polarsignals-scraper-config
name: polarsignals-scraper-config
- secret:
secretName: polarsignals-agent
name: token
---
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
app.kubernetes.io/component: profile-scraper
app.kubernetes.io/instance: polarsignals-scraper
app.kubernetes.io/name: polarsignals-scraper
name: polarsignals-scraper
namespace: polarsignals

Configuration

The configuration is identical to the Prometheus scrape config. Anything described in the Prometheus documentation can be used to configure the Polar Signals Scraper too.

A common thing to do is not scrape all containers in a Kubernetes cluster, but only a specific container name for example. That can be done by adding the following snippet:

      - source_labels: [__meta_kubernetes_pod_container_name]
action: keep
regex: my-container

If you ever need help with specific changes to your configuration feel free to join our Discord server and ask!