# Fluentd Using Scribe Protocol to Store Logs

td-agent was discontinued in December 2023 and has been replaced by **fluent-package**. The fluent-package is the official successor maintained by the [Cloud Native Computing Foundation](https://www.cncf.io/projects/).

Fluentd understands the Scribe protocol (Thrift-based). Fluentd can co-exist or replace your existing Scribe infrastructure.

See [fluent-plugin-scribe](https://github.com/fluent/fluent-plugin-scribe). The plugin also supports Scribe *output*.

* [Prerequisites](#prerequisites)
* [Specifying Use of Scribe Input](#specifying-use-of-scribe-input)
* [Messages as JSON String](#messages-as-json-string)
* [Other Formats](#other-formats)


## Prerequisites

* Basic knowledge of Treasure Data, including the [TD Toolbelt](/tools/cli-and-sdks/td-toolbelt).
* Basic knowledge of Fluentd.


## Specifying Use of Scribe Input

The following configuration enables the Scribe input plugin:


```conf
<source>
  @type scribe
  port 1463
</source>
```

The `category` field of the Scribe protocol is used as a `tag` for Fluentd. If you want to store your data in the www_access table within the test_db database, send your LogEntry as follows (Ruby example).


```ruby
LogEntry.new
entry.category = 'td.test_db.www_access'
entry.message = 'abcde'
client.Log([entry])
```

This message is organized as follows.


```ruby
{
  message => 'abcde'
}
```

## Messages as JSON String

The message field of semi-structured data often contains JSON strings. Fluentd uses the *msg_format* option to parse the JSON string in-place.


```conf
<source>
  @type scribe
  port 1463
  msg_format json
</source>
```

Send records as follows. Note that entry.message is a JSON string.


```ruby
entry = LogEntry.new
entry.category = 'td.test_db.www_access'
entry.message = {'a' => 'b', 'c' => d}.to_json
client.Log([entry])
```

This message is organized as follows.


```ruby
{
  'a' => 'b',
  'c' => 'd',
}
```

## Other Formats

The *msg_format* option supports `text`, `json`, and `url_param`. The format for `url_param` is as follows.

`key1=val1&key2=val2&key3=val3`