# Shell

Contents

* [Shell](https://docs.hostedgraphite.com/language-guide/shell)
  * [Sending a metric via TCP](#sending-a-metric-via-tcp)
  * [Sending a metric via UDP](#sending-a-metric-via-udp)
  * [Sending a metric via TCP over TLS](#sending-a-metric-via-tcp-over-tls)
  * [Sending a metric via HTTPs](#sending-a-metric-via-https)
  * [Sending a metric via StatsD](#sending-a-metric-via-statsd)
  * [Sending multiple metrics with Curl](#sending-multiple-metrics-with-curl)

### [Sending a metric via TCP](#sending-a-metric-via-tcp)

Using the [netcat](http://netcat.sourceforge.net/) utility

```
echo "YOUR-API-KEY.foo 1.2" | nc carbon.hostedgraphite.com 2003
```

### [Sending a metric via UDP](#sending-a-metric-via-udp)

Using the [netcat](http://netcat.sourceforge.net/) utility

```
echo "YOUR-API-KEY.foo 1.2" | nc -uw0 carbon.hostedgraphite.com 2003
```

### [Sending a metric via TCP over TLS](#sending-a-metric-via-tcp-over-tls)

Using the [Ncat](https://nmap.org/ncat/) utility

```
echo "YOUR-API-KEY.con_users 1.3" | ncat --ssl carbon.hostedgraphite.com 20030
```

Alternatively, the following example using [OpenSSL](https://www.openssl.org/) should work out of the box in OS X:

```
echo "YOUR-API-KEY.con_users 1.3" |  openssl s_client -connect carbon.hostedgraphite.com:20030
```

### [Sending a metric via HTTPs](#sending-a-metric-via-https)

Using the [Curl](https://curl.haxx.se/) utility

```
curl https://YOUR-API-KEY@www.hostedgraphite.com/api/v1/sink --data-binary "foo 1.2"
```

### [Sending a metric via StatsD](#sending-a-metric-via-statsd)

Using the [Ncat](https://nmap.org/ncat/) utility:

```
echo "YOUR-API-KEY.foo.statsd:1.2|c" | nc -u -w1 statsd.hostedgraphite.com 8125
```

For StatsD, make sure to specify counters (c), gauges (g), or timers (ms).

### [Sending multiple metrics with Curl](#send-multiple-metrics-with-curl)

```
curl https://YOUR-API-KEY@www.hostedgraphite.com/api/v1/sink --data-binary @data.txt
```

where data.txt contains multiple metrics and values on a separate line:

Your API key can be found on your [account home](https://www.hostedgraphite.com/accounts/profile/) page.
